Skip to content

Xmake leetcode treenode cpp insert_into_a_binary_search_tree #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,14 @@ jobs:
xmake build -v -y
xmake run -v


- name: make test insert-into-a-binary-search-tree

run: |
cd insert-into-a-binary-search-tree


xmake f --toolchain=llvm --sdk=/usr/local/opt/llvm/ -y -v
xmake build -v -y
xmake run -v

8 changes: 8 additions & 0 deletions insert-into-a-binary-search-tree/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Xmake cache
.xmake/
build/

# MacOS Cache
.DS_Store


83 changes: 83 additions & 0 deletions insert-into-a-binary-search-tree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# this is the build file for project
# it is autogenerated by the xmake build system.
# do not edit by hand.

# project
cmake_minimum_required(VERSION 3.15.0)
cmake_policy(SET CMP0091 NEW)
project(test LANGUAGES CXX C)

# target
add_executable(test "" debugTreeNode.mxx EqualTreeNode.mxx index.mxx printTreeNode.mxx HashTreeNode.mxx)
set_target_properties(test PROPERTIES OUTPUT_NAME "test")
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/windows/x64/release")
add_custom_command(OUTPUT output_test_1F049C3C
COMMAND echo [ 0%]: compiling.module.release printTreeNode.mxx
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX64/x64/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -external:W0 -external:IC:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include -external:W0 -external:IC:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/printTreeNode.mxx -Fo${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/printTreeNode.mxx.obj
COMMAND echo [ 0%]: compiling.module.release index.mxx
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX64/x64/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -external:W0 -external:IC:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include -external:W0 -external:IC:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/index.mxx -Fo${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/index.mxx.obj
COMMAND echo [ 0%]: compiling.module.release HashTreeNode.mxx
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX64/x64/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -external:W0 -external:IC:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include -external:W0 -external:IC:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/HashTreeNode.mxx -Fo${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/HashTreeNode.mxx.obj
COMMAND echo [ 0%]: compiling.module.release EqualTreeNode.mxx
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX64/x64/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -external:W0 -external:IC:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include -external:W0 -external:IC:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/EqualTreeNode.mxx -Fo${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/EqualTreeNode.mxx.obj
COMMAND echo [ 0%]: compiling.module.release debugTreeNode.mxx
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release
COMMAND "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.35.32215/bin/HostX64/x64/cl.exe" -nologo -O2 -fp:fast -std:c++20 /EHsc -external:W0 -external:IC:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include -external:W0 -external:IC:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include -experimental:module -DNDEBUG -TP -c ${CMAKE_SOURCE_DIR}/debugTreeNode.mxx -Fo${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/debugTreeNode.mxx.obj
VERBATIM
)
add_custom_target(target_test_1F049C3C
DEPENDS output_test_1F049C3C
)
add_dependencies(test target_test_1F049C3C)
target_include_directories(test PRIVATE
C:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/include
C:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/include
)
target_compile_options(test PRIVATE
$<$<COMPILE_LANGUAGE:C>:-DNDEBUG>
$<$<COMPILE_LANGUAGE:CXX>:-DNDEBUG>
$<$<COMPILE_LANGUAGE:CXX>:-experimental:module>
)
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_compile_options(test PRIVATE /EHsc)
else()
target_compile_options(test PRIVATE -fcxx-exceptions)
endif()
set_target_properties(test PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(test PRIVATE cxx_std_20)
if(MSVC)
target_compile_options(test PRIVATE $<$<CONFIG:Release>:-Ox -fp:fast>)
else()
target_compile_options(test PRIVATE -O3)
endif()
if(MSVC)
else()
target_compile_options(test PRIVATE -fvisibility=hidden)
endif()
if(MSVC)
set_property(TARGET test PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(test PRIVATE
cppunit
leetcode-treenode-cpp
)
target_link_libraries(test PRIVATE
${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/debugTreeNode.mxx.obj
${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/EqualTreeNode.mxx.obj
${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/HashTreeNode.mxx.obj
${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/index.mxx.obj
${CMAKE_SOURCE_DIR}/build/.objs/test/windows/x64/release/printTreeNode.mxx.obj
)
target_link_directories(test PRIVATE
C:/Users/Administrator/Documents/vcpkg-master/installed/x64-windows-static/lib
C:/Users/Administrator/AppData/Local/.xmake/packages/l/leetcode-treenode-cpp/1.1.4/1fe8830461144a9a9a2e83efa281352c/lib
)
target_sources(test PRIVATE
test.cpp
)

Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
// +build ignore

#pragma once
module;

//#pragma once

export module insert_into_a_binary_search_tree.EqualTreeNode;

// #include "TreeNode.hpp"

import leetcode_treenode_cpp.TreeNode;
using namespace leetcode_treenode_cpp;

namespace insert_into_a_binary_search_tree{
export
struct EqualTreeNode {
bool operator()(const TreeNode* lhs, const TreeNode* rhs) const
{
return lhs == rhs;
}
};
};}
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// +build ignore

#pragma once
// #include "TreeNode.hpp"
module;

//#pragma once


#include <functional>

#include <cstdlib>


#include <stdio.h>

export module insert_into_a_binary_search_tree.HashTreeNode;
import leetcode_treenode_cpp.TreeNode;
using namespace leetcode_treenode_cpp;
namespace insert_into_a_binary_search_tree{
export
struct HashTreeNode {
std::size_t operator()(const TreeNode* k) const
{
return std::hash<long long>()((long long)k);
}
};
};}
25 changes: 0 additions & 25 deletions insert-into-a-binary-search-tree/debugTreeNode.hpp

This file was deleted.

38 changes: 38 additions & 0 deletions insert-into-a-binary-search-tree/debugTreeNode.mxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// +build ignore


module;


//#pragma once
#include <string>

// #include "TreeNode.hpp"
#include <sstream>
export module insert_into_a_binary_search_tree.debugTreeNode;


import leetcode_treenode_cpp.TreeNode;
using namespace leetcode_treenode_cpp;

using namespace std;
namespace insert_into_a_binary_search_tree{
export

string debugTreeNode(TreeNode* root)
{

stringstream sstream;
if (root == NULL) {

sstream << "null";
return sstream.str();
}

sstream << "TreeNode"; //@" << root;
sstream << "{\nval:" << root->val;
sstream << ",left:" << debugTreeNode(root->left);
sstream << ",right:" << debugTreeNode(root->right) << "\n}";
return sstream.str();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// +build ignore

#pragma once
module;
//#pragma once

#include <stdio.h>

export module insert_into_a_binary_search_tree.Solution;
import leetcode_treenode_cpp.TreeNode;
using namespace leetcode_treenode_cpp;

namespace insert_into_a_binary_search_tree
{
{export
class Solution
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@
<ClCompile Include="test.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="debugTreeNode.hpp" />
<ClInclude Include="EqualTreeNode.hpp" />
<ClInclude Include="HashTreeNode.hpp" />
<ClInclude Include="index.hpp" />
<ClInclude Include="printTreeNode.hpp" />
<ClInclude Include="parseLeetCodeBinaryTree.hpp" />
<None Include="debugTreeNode.mxx" />
<None Include="EqualTreeNode.mxx" />
<None Include="HashTreeNode.mxx" />
<None Include="index.mxx" />
<None Include="printTreeNode.mxx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
Expand Down Expand Up @@ -41,23 +37,20 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="debugTreeNode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EqualTreeNode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HashTreeNode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="index.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="printTreeNode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="parseLeetCodeBinaryTree.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<None Include="HashTreeNode.mxx">
<Filter>Source Files</Filter>
</None>
<None Include="printTreeNode.mxx">
<Filter>Source Files</Filter>
</None>
<None Include="EqualTreeNode.mxx">
<Filter>Source Files</Filter>
</None>
<None Include="index.mxx">
<Filter>Source Files</Filter>
</None>
<None Include="debugTreeNode.mxx">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
// +build ignore

#pragma once
module;

#include <string>
using namespace std;
// #include "TreeNode.hpp"
#include "debugTreeNode.hpp"



#include <iostream>
#include <sstream>
export module insert_into_a_binary_search_tree.printTreeNode;

import leetcode_treenode_cpp.TreeNode;

import insert_into_a_binary_search_tree.debugTreeNode;

using namespace std;

using namespace leetcode_treenode_cpp;



namespace insert_into_a_binary_search_tree
{


export
void printTreeNode(TreeNode* node)
{

auto s = debugTreeNode(node);
cout << s << endl;
return;
}
}
}
Loading