The most efficient tree structure for what I'm trying to do

I am wondering what the most efficient tree structure would be for a collection that has the following requirements:

  • The tree will be somewhere between 0 and 2 32 - 1 element.
  • Each element will be a simple structure containing one 32-bit unsigned integer (a unique identifier for the element that will be used as the value of the tree) and two pointers.
  • Elements will be inserted and removed from the tree very often; some elements in the tree will remain there for the duration of the program, while others will only be in the tree very briefly before being deleted.
  • After an element is deleted, its unique identifier (this is a 32-bit unsigned integer) will be recycled and reused for the new element.

The tree structure must support efficient insertions and deletions, as well as a quick search by unique identifier. Also, finding the first available unused unique identifier should be a quick operation.

Which tree is best suited for these requirements?

EDIT: this tree will only be stored in memory; in no case will it be saved to disk. I don’t need to worry about getting to disk, disk caching or anything like that. That is why I am not looking for something like SQLite.

+3
source share
8 answers

- trie? , , - , .

, , , , , .

+2

, , , mmap-ed . . , , . 1 2 ( ). , .

, , , .

: " "

, 2 ^ 32 ( , ), , , ​​ . - . , , , . mmap ( - ) , , , .

, ( , mmap B- Black-Red - ), . , . , B-tree ( ), , ( ) ( LRU), , .

: , . , 10 ^ -9 10 ^ -3. 1 .  TANSTAAFL!

+5

, , , stl. , , , , , - , . , , , .. .

AVL, . AVL , , , .

+1

, 2 ^ 32-1 ? SQLite. , , , . , .

, BTree. - , , .

, , , . , . , .

+1

boost::unordered_map , . , .

, , , , . , , , -. , boost boost: hash function. , ; .

(: , -, "". , , - ( )?)

0

?

, . , - .

. (2 ^ 32 ), 4 8 . , .

0

32- , , . ?

, . . , -. , , . 512 , .

, . , , , node . memset(), node. , node. node, . node, , , . ( node, , node -.)

It will probably take about 64 GB or 96 GB of RAM, but this is less than the solution of the card.

0
source

Source: https://habr.com/ru/post/1725233/


All Articles