neuray API Programmer's Manual

mi::IMap Class Reference

[Collections]

Description

This interface represents maps, i.e., a key-value based data structure. Maps are either typed or untyped. Keys are always strings. Typed maps enforce all values to be of the same type. The values of typed maps have to be derived from mi::IData. The type name of a typed map is "Map<", followed by the type name the values, and finally ">", e.g., "Map<Sint32>" for a map with values of type mi::Sint32. Initially, a map is empty, i.e., no keys exist.

Untyped maps simply store pointers of type mi::base::IInterface. The type name of an untyped map is "Map<Interface>".

Most methods of mi::IData_collection come in two versions, an index-based and a key-based version. Since a map is a key-based data structure, the key-based variants of the methods of mi::IData_collection are more efficient (logarithmic time). In general, the index-based methods require linear time (in particular for random access patterns). As an exception, accessing the indices in sequence from 0 to get_length()-1 requires only constant time per access (provided the structure of the map is not changed, the values of the keys may change). The mapping of indices to keys is unspecified.

Public Member Functions

virtual void clear() =0
Removes all keys and their associated values from the map.
virtual bool  empty() const =0
Checks whether the map is empty. More...
virtual Sint32 erase( const char* key) =0
Removes a key and its value from the map. More...
virtual Size get_length() const =0
Returns the size of the map. More...
virtual Sint32 insert( const char* key, base::​IInterface* value) =0
Inserts a new key including its value into the map. More...

Member Functions

virtual void mi::​IMap::clear() [pure virtual]

Removes all keys and their associated values from the map.

virtual bool mi::​IMap::empty() const [pure virtual]

Checks whether the map is empty. Equivalent to get_length() == 0.

virtual Sint32 mi::​IMap::erase( const char* key) [pure virtual]

Removes a key and its value from the map.

Returns

  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: key does not exist

virtual Size mi::​IMap::get_length() const [pure virtual]

Returns the size of the map. The size of a map is the number of keys in the map.

virtual Sint32 mi::​IMap::insert( const char* key, base::​IInterface* value) [pure virtual]

Inserts a new key including its value into the map.

Returns

  • 0: Success.
  • -1: Invalid parameters (NULL pointer).
  • -2: key exists already.
  • -3: value has the wrong type.