-
Notifications
You must be signed in to change notification settings - Fork 111
Improve red-black tree implementation in map #29
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
Comments
commit 7fb4ff7 integrates color into lowest bit of parent pointer. |
The expected improvements can be the followings:
|
rbi is non-recursive, and has very little memory overhead (e.g. no parent pointer within the red-black tree node). Its features:
We might learn from rbi. |
Below is my proposal for the first change.
I will also write testing to ensure the correctness of all functions. What do you think? |
The following result is recorded by the simple benchmark I created.
|
You shall provide the corresponding benchmark programs for reference purpose. In particular, rbi.c lacks of the ability to remove. rb.h is exactly used for comparison. |
Repository: rbtree_bench
|
The following changes are required. --- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.11)
+cmake_minimum_required (VERSION 3.14)
project (rbtree_bench)
@@ -10,6 +10,7 @@ FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
+FetchContent_MakeAvailable(googletest)
add_subdirectory (map)
add_subdirectory (rb)
diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt
index 2701980..a67cbb5 100644
--- a/map/CMakeLists.txt
+++ b/map/CMakeLists.txt
@@ -1,4 +1,3 @@
-cmake_minimum_required(VERSION 3.5)
project(map)
enable_testing()
diff --git a/rb/CMakeLists.txt b/rb/CMakeLists.txt
index 06ab4d7..8bdf88d 100644
--- a/rb/CMakeLists.txt
+++ b/rb/CMakeLists.txt
@@ -1,10 +1,7 @@
-cmake_minimum_required(VERSION 3.5)
project(rbi)
enable_testing()
-find_package(GTest CONFIG REQUIRED)
-
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(GCC_FLAGS "-s -Os -W -Wall -Werror") |
Tested on eMag 8180, 64-bit 32-core Arm server.
|
See also: |
Action items for rbtree_bench:
|
Close via commit 434c466 |
map.[ch]
is the C Implementation for C++ std::map using red-black tree. It works well, but there is room for improvements. We can take some tricks used in Red-black Trees in Linux for potential speedup. In addition, current rbtree can benefit from the introduction of indirect pointers.The text was updated successfully, but these errors were encountered: