Skip to content

Commit

Permalink
WIP add btree_set
Browse files Browse the repository at this point in the history
with node size of 256, as in abseil.
also using similar tricks as abseil, using much less memory per node.
  • Loading branch information
rurban committed Feb 20, 2024
1 parent 93174c7 commit adce7ab
Show file tree
Hide file tree
Showing 7 changed files with 1,507 additions and 40 deletions.
13 changes: 11 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ TESTS = \

ifneq ($(DEBUG),)
TESTS += \
tests/func/test_map \
tests/func/test_btree_set \
tests/func/test_btree_map \
tests/func/test_map \
tests/func/test_unordered_map
endif

Expand Down Expand Up @@ -186,6 +188,7 @@ perf: $(PERFS_C) $(PERFS_CC) tests/perf/arr/perf_arr_generate

$(wildcard tests/perf/lst/perf*.cc?) : $(COMMON_H) ctl/list.h
$(wildcard tests/perf/set/perf*.cc?) : $(COMMON_H) ctl/set.h
$(wildcard tests/perf/btset/perf*.cc?) : $(COMMON_H) ctl/btree_set.h
$(wildcard tests/perf/deq/perf*.cc?) : $(COMMON_H) ctl/deque.h
$(wildcard tests/perf/pqu/perf*.cc?) : $(COMMON_H) ctl/priority_queue.h
$(wildcard tests/perf/vec/perf*.cc?) : $(COMMON_H) ctl/vector.h
Expand Down Expand Up @@ -292,6 +295,8 @@ ctl/string.i:
$(call expand,$(subst .i,,$@))
ctl/map.i:
$(call expand,$(subst .i,,$@),-DT=strint -DPOD)
ctl/btree_map.i:
$(call expand,$(subst .i,,$@),-DT=strint -DPOD)
ctl/unordered_map.i:
$(call expand,$(subst .i,,$@),-DT=strint -DPOD)
ctl/array.i:
Expand Down Expand Up @@ -328,7 +333,11 @@ tests/func/test_queue: .cflags $(COMMON_H) tests/test.h tests/func/digi.hh ct
tests/func/test_set: .cflags $(COMMON_H) tests/test.h tests/func/digi.hh ctl/set.h \
tests/func/test_set.cc
$(CXX) $(CXXFLAGS) -o $@ [email protected]
tests/func/test_map: .cflags $(H) tests/test.h tests/func/strint.hh ctl/set.h ctl/map.h tests/func/test_map.cc
tests/func/test_btree_set: .cflags $(COMMON_H) tests/test.h tests/func/digi.hh ctl/btree_set.h \
tests/func/test_btree_set.cc
$(CXX) $(CXXFLAGS) -o $@ [email protected]
tests/func/test_map: .cflags $(H) tests/test.h tests/func/strint.hh \
tests/func/test_map.cc
$(CXX) $(CXXFLAGS) -o $@ [email protected]
tests/func/test_unordered_set: .cflags $(COMMON_H) ctl/unordered_set.h \
tests/func/test_unordered_set.cc
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ all containers in ISO C99/C11:
| [ctl/map.h](docs/map.md) | std::map | map |
| [ctl/unordered_map.h](docs/unordered_map.md) | std::unordered_map | umap |
| [ctl/unordered_set.h](docs/unordered_set.md) | std::unordered_set | uset |
| [ctl/btree_set.h](docs/btree_set.md) | absl::btree_set | btset |
| [ctl/btree_map.h](docs/btree_map.md) | absl::btree_map | btmap |
|------------------------------------------------|----------------------|
| [ctl/algorithm.h](docs/algorithm.md) | `<algorithm>` |
| [ctl/numeric.h](docs/numeric.md) | `<numeric>` |
Expand Down Expand Up @@ -359,7 +361,6 @@ And in its grandiosity (esp. not header-only):

## Base Implementation Details


array.h: stack/heap allocated
vector.h: realloc
string.h: vector.h
Expand All @@ -371,6 +372,8 @@ And in its grandiosity (esp. not header-only):
forward_list.h: single linked list
set.h: red black tree
map.h: set.h
btree_set.h: b-tree
btree_map.h: - " -
unordered_set.h: hashed forward linked lists
unordered_map.h: unordered_set.h (pair in work)
hashmap.h: stanford hash for integer keys, intel only.
Expand Down
Loading

0 comments on commit adce7ab

Please sign in to comment.