Mission Base

Program Base Library

pblMap - Map Implementation

Map in C, C hash map, C-HashMap, hash map in C, HashMap in C, C tree map, C-TreeMap, tree map in C, TreeMap in C.


Documentation

Open source C implementation of a map. A map maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This C implementation is similar to the Java Map interface.

The Map module provides two implementations of maps, an open source C hash map implementation equivalent to the Java HashMap class and a sorted open source C avl-tree-based balanced tree map implementation equivalent to the Java TreeMap class.

Hash maps make no guarantees as to the iteration order of the map; in particular, they do not guarantee that the order will remain constant over time. Hash maps offer constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets. Iterating over hash maps requires time proportional to the sum of the hash map instance's size (the number of elements) plus the "capacity" of the map (the number of buckets). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important.

Tree maps being sorted guarantee that the map can be iterated in ascending element order, according to the compare function specified for the map. The implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains). Iterating over tree maps requires time proportional to the tree map instance's size.

The Map module provides an iterator, called a pblIterator, that allows bidirectional access in addition to the normal operations iterators provide.

All map functions described below work on hash maps as well as on tree maps, they of course will show different runtime and memory complexities depending on the type of map used.


Constructors and Destructors

  • pblMapNewHashMap Creates a new hash map.
  • pblMapNewTreeMap Creates a new tree map.
  • pblMapFree Removes all of the mappings from this map and frees the map's memory from heap.
  • pblMapClear Removes all of the mappings from this map.

    Adding to a Map

  • pblMapAdd Associates the specified value with the specified key in this map.
  • pblMapAddStrStr Associates the specified string value with the specified string key in this map.
  • pblMapPut Associates the specified value with the specified key in this map.
  • pblMapPutAll Copies all of the mappings from the specified source map to this map.
  • pblMapPutStrStr Associates the specified string value with the specified string key in this map.

    Accessing Map Elements

  • pblMapContainsKey Returns true if this map contains a mapping for the specified key.
  • pblMapContainsKeyStr Returns true if this map contains a mapping for the specified string key.
  • pblMapContainsValue Returns true if this map contains a mapping for the specified value.
  • pblMapContainsValueStr Returns true if this map contains a mapping for the specified string value.
  • pblMapGet Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
  • pblMapGetStr Returns the value to which the specified string key is mapped, or null if this map contains no mapping for the key.

    Removing from a Map

  • pblMapClear Removes all of the mappings from this map.
  • pblMapFree Removes all of the mappings from this map and frees the map's memory from heap.
  • pblMapRemove Removes the mapping for this key from this map if it is present.
  • pblMapRemoveStr Removes the mapping for this string key from this map if it is present.

    Functions on Map Entries

  • pblMapEntryKey Returns a pointer to the key of the map entry passed.
  • pblMapEntryKeyLength Returns the key length of the map entry passed.
  • pblMapEntryValue Returns a pointer to the value of the map entry passed.
  • pblMapEntryValueLength Returns the value length of the map entry passed.

    Functions on Maps

  • pblMapIsEmpty Tests if this map has no elements.
  • pblMapIteratorNew Returns an iterator over the map entries in this map in proper sequence.
  • pblMapIteratorReverseNew Returns a reverse iterator over the elements in this map in proper sequence.
  • pblMapSize Returns the number of entries in this map.

    Alphabetic List of Map Functions

  • pblMapAdd Associates the specified value with the specified key in this map.
  • pblMapAddStrStr Associates the specified string value with the specified string key in this map.
  • pblMapClear Removes all of the mappings from this map.
  • pblMapContainsKey Returns true if this map contains a mapping for the specified key.
  • pblMapContainsKeyStr Returns true if this map contains a mapping for the specified string key.
  • pblMapContainsValue Returns true if this map contains a mapping for the specified value.
  • pblMapContainsValueStr Returns true if this map contains a mapping for the specified string value.
  • pblMapEntryKey Returns a pointer to the key of the map entry passed.
  • pblMapEntryKeyLength Returns the key length of the map entry passed.
  • pblMapEntryValue Returns a pointer to the value of the map entry passed.
  • pblMapEntryValueLength Returns the value length of the map entry passed.
  • pblMapFree Removes all of the mappings from this map and frees the map's memory from heap.
  • pblMapGet Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
  • pblMapGetStr Returns the value to which the specified string key is mapped, or null if this map contains no mapping for the key.
  • pblMapIsEmpty Tests if this map has no elements.
  • pblMapIteratorNew Returns an iterator over the map entries in this map in proper sequence.
  • pblMapIteratorReverseNew Returns a reverse iterator over the elements in this map in proper sequence.
  • pblMapNewHashMap Creates a new hash map.
  • pblMapNewTreeMap Creates a new tree map.
  • pblMapPut Associates the specified value with the specified key in this map.
  • pblMapPutAll Copies all of the mappings from the specified source map to this map.
  • pblMapPutStrStr Associates the specified string value with the specified string key in this map.
  • pblMapRemove Removes the mapping for this key from this map if it is present.
  • pblMapRemoveStr Removes the mapping for this string key from this map if it is present.
  • pblMapSize Returns the number of entries in this map.

    Alphabetic index


    GET PBL:


    Copyright(C) 2003 - 2015 Peter Graf, this software is distributed under the MIT License.
    This page was generated with the help of DOC++.