the_Foundation 1.0
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
map.h File Reference
#include "defs.h"
#include "list.h"
#include "class.h"

Data Structures

struct  iMap
 
struct  iMapNode
 Nodes inserted to the map must be based on iMapNode. More...
 
struct  iMapReverseIterator
 
struct  iMapReverseConstIterator
 

Typedefs

typedef int64_t iMapKey
 
typedef int(* iMapNodeCmpFunc) (iMapKey, iMapKey)
 

Functions

iMap * new_Map (iMapNodeCmpFunc cmp)
 
void delete_Map (iMap *)
 
void init_Map (iMap *, iMapNodeCmpFunc cmp)
 
void deinit_Map (iMap *)
 
iBool contains_Map (const iMap *, iMapKey key)
 
iMapNode * value_Map (const iMap *, iMapKey key)
 
void clear_Map (iMap *)
 
iMapNode * insert_Map (iMap *, iMapNode *node)
 
iMapNode * remove_Map (iMap *, iMapKey key)
 
iMapNode * removeNode_Map (iMap *, iMapNode *node)
 
Iterators
void init_MapIterator (iMapIterator *, iMap *)
 
void next_MapIterator (iMapIterator *)
 
void init_MapReverseIterator (iMapReverseIterator *, iMap *)
 
void next_MapReverseIterator (iMapReverseIterator *)
 
iMapNode * remove_MapIterator (iMapIterator *d)
 
iMapNode * remove_MapReverseIterator (iMapReverseIterator *d)
 
void init_MapConstIterator (iMapConstIterator *, const iMap *)
 
void next_MapConstIterator (iMapConstIterator *)
 
void init_MapReverseConstIterator (iMapReverseConstIterator *, const iMap *)
 
void next_MapReverseConstIterator (iMapReverseConstIterator *)
 

Detailed Description

Map of sorted unique integer nodes.

Map is implemented as a red-black tree, i.e., a balanced BST.

Map does not have ownership of the nodes. This means the nodes can be any type of object as long as they are derived from MapNode.

Authors
Copyright (c) 2017 Jaakko Keränen jaakk.nosp@m.o.ke.nosp@m.ranen.nosp@m.@iki.nosp@m..fi
License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ insert_Map()

iMapNode * insert_Map ( iMap * ,
iMapNode * node )

Inserts a node into the map.

Parameters
nodeNode to be inserted. Ownership not taken. The key member must be set to the key value.
Returns
Previous node with the same key that had to be removed from the hash to make room for the new node. The caller should delete the node or take any other necessary actions, since it is no longer part of the hash.