14 typedef struct _TreeMap {
20 int32_t (*put) (
struct _TreeMap*, Pair*);
24 int32_t (*
get) (
struct _TreeMap*, Key, Value*);
28 int32_t (*find) (
struct _TreeMap*, Key);
32 int32_t (*
remove) (
struct _TreeMap*, Key);
36 int32_t (*size) (
struct _TreeMap*);
40 int32_t (*minimum) (
struct _TreeMap*, Pair**);
44 int32_t (*maximum) (
struct _TreeMap*, Pair**);
48 int32_t (*predecessor) (
struct _TreeMap*, Key, Pair**);
52 int32_t (*successor) (
struct _TreeMap*, Key, Pair**);
56 int32_t (*iterate) (
struct _TreeMap*, bool, Pair**);
60 int32_t (*reverse_iterate) (
struct _TreeMap*, bool, Pair**);
64 int32_t (*set_compare) (
struct _TreeMap*, int32_t (*) (Key, Key));
68 int32_t (*set_destroy) (
struct _TreeMap*, void (*) (Pair*));
The implementation for ordered map.
int32_t TreeMapPredecessor(TreeMap *self, Key key, Pair **ppPair)
Retrieve the key value pair which is the predecessor of the given key.
int32_t TreeMapPut(TreeMap *self, Pair *pPair)
Insert a key value pair into the map.
int32_t TreeMapSuccessor(TreeMap *self, Key key, Pair **ppPair)
Retrieve the key value pair which is the successor of the given key.
int32_t TreeMapMinimum(TreeMap *self, Pair **ppPair)
Retrieve the key value pair with the minimum order from the map.
int32_t TreeMapSetCompare(TreeMap *self, int32_t(*pFunc)(Key, Key))
Set the custom key comparison method.
int32_t TreeMapIterate(TreeMap *self, bool bReset, Pair **ppPair)
Iterate through the map from the minimum order to the maximum order.
int32_t TreeMapFind(TreeMap *self, Key key)
Check if the map contains the designated key.
TreeMapData * pData
The container private information.
int32_t TreeMapRemove(TreeMap *self, Key key)
Delete the key value pair corresponding to the designated key.
struct _TreeMapData TreeMapData
TreeMapData is the data type for the container private information.
int32_t TreeMapMaximum(TreeMap *self, Pair **ppPair)
Retrieve the key value pair with the maximum order from the map.
int32_t TreeMapGet(TreeMap *self, Key key, Value *pValue)
Retrieve the value corresponding to the designated key.
int32_t TreeMapSetDestroy(TreeMap *self, void(*pFunc)(Pair *))
Set the custom key value pair resource clean method.
int32_t TreeMapSize(TreeMap *self)
Return the number of stored key value pairs.
int32_t TreeMapReverseIterate(TreeMap *self, bool bReset, Pair **ppPair)
Reversely iterate through the map from the minimum order to the maximum order.
void TreeMapDeinit(TreeMap **ppObj)
The destructor for TreeMap.
int32_t TreeMapInit(TreeMap **ppObj)
The constructor for TreeMap.