#include <lockfree_set.h>
Public Member Functions | |
Set (int expectedSetSize=DEFAULT_SEGMENT_SIZE *DEFAULT_ARRAY_SIZE, float expectedLoadFactor=MAX_LOAD) | |
Create a new set with explicitly specified expected size and load factor. The number of dummy nodes has a maximum of expectedSize This isn't a limitation of actual elements stored in set. But the average search number will increase if number of elements is bigger than expectedSize. | |
~Set () | |
Destructor, supposed to be called when its associated data structure is to be deleted. | |
bool | empty () |
Judge if the set is empty. | |
unsigned int | size () |
Get the size of set. | |
bool | insert (KeyType element) |
Add the specified element into the set. | |
bool | remove (KeyType element) |
Remove a specified element by value. | |
bool | search (const KeyType &element) |
Judge if a specified element is in the set. |
The internal data structure is a single linked LockFreeOrderedList. Elements are sorted by "binary reversal" of hash key of elements. Additionally, an array of dummy nodes is stored for allowing quick access to elements in the middle of lock-free ordered list. Elements are wrapped by SetNode before stored into set.
KeyType | Type of elements stored in the set |
amino::Set< KeyType >::Set | ( | int | expectedSetSize = DEFAULT_SEGMENT_SIZE * DEFAULT_ARRAY_SIZE , |
|
float | expectedLoadFactor = MAX_LOAD | |||
) | [inline, explicit] |
Create a new set with explicitly specified expected size and load factor. The number of dummy nodes has a maximum of expectedSize This isn't a limitation of actual elements stored in set. But the average search number will increase if number of elements is bigger than expectedSize.
expectedSetSize | The expected size of set | |
expectedLoadFactor | Average load factor. Number of dummy nodes will expand 2X if the actual load factor is higher than this parameter. |
amino::Set< KeyType >::~Set | ( | ) | [inline] |
Destructor, supposed to be called when its associated data structure is to be deleted.
bool amino::Set< KeyType >::empty | ( | ) | [inline] |
Judge if the set is empty.
unsigned int amino::Set< KeyType >::size | ( | ) | [inline] |
Get the size of set.
bool amino::Set< KeyType >::insert | ( | KeyType | element | ) | [inline] |
Add the specified element into the set.
element | The element to be added |
bool amino::Set< KeyType >::remove | ( | KeyType | element | ) | [inline] |
bool amino::Set< KeyType >::search | ( | const KeyType & | element | ) | [inline] |
Judge if a specified element is in the set.
element | The element to be searched |