DiCE API nvidia_logo_transpbg.gif Up
mi::IMap Class Referenceabstract

This interface represents maps, i.e., a key-value based data structure. More...

#include <imap.h>

Inheritance diagram for mi::IMap:

Public Member Functions

virtual Size get_length () const =0
 Returns the size of the map. More...
 
virtual bool empty () const =0
 Checks whether the map is empty. More...
 
virtual void clear ()=0
 Removes all keys and their associated values from the map. More...
 
virtual Sint32 insert (const char *key, base::IInterface *value)=0
 Inserts a new key including its value into the map. More...
 
virtual Sint32 erase (const char *key)=0
 Removes a key and its value from the map. More...
 
- Public Member Functions inherited from mi::IData_collection
virtual Size get_length () const =0
 Returns the number of values. More...
 
virtual const char * get_key (Size index) const =0
 Returns the key corresponding to index. More...
 
virtual bool has_key (const char *key) const =0
 Indicates whether the key key exists or not. More...
 
virtual const base::IInterfaceget_value (const char *key) const =0
 Returns the value for key key. More...
 
template<class T>
const T * get_value (const char *key) const
 Returns the value for key key. More...
 
virtual base::IInterfaceget_value (const char *key)=0
 Returns the value for key key. More...
 
template<class T>
T * get_value (const char *key)
 Returns the value for key key. More...
 
virtual const base::IInterfaceget_value (Size index) const =0
 Returns the value for index index. More...
 
template<class T>
const T * get_value (Size index) const
 Returns the value for index index. More...
 
virtual base::IInterfaceget_value (Size index)=0
 Returns the value for index index. More...
 
template<class T>
T * get_value (Size index)
 Returns the value for index index. More...
 
virtual Sint32 set_value (const char *key, base::IInterface *value)=0
 Stores the value for key key. More...
 
virtual Sint32 set_value (Size index, base::IInterface *value)=0
 Stores the value for index index. More...
 
- Public Member Functions inherited from mi::IData
virtual const char * get_type_name () const =0
 Returns the type name. More...
 
- Public Member Functions inherited from mi::base::IInterface
virtual Uint32 retain () const =0
 Increments the reference count. More...
 
virtual Uint32 release () const =0
 Decrements the reference count. More...
 
virtual const IInterfaceget_interface (const Uuid &interface_id) const =0
 Acquires a const interface from another. More...
 
template<class T>
const T * get_interface () const
 Acquires a const interface from another. More...
 
virtual IInterfaceget_interface (const Uuid &interface_id)=0
 Acquires a mutable interface from another. More...
 
template<class T>
T * get_interface ()
 Acquires a mutable interface from another. More...
 
virtual Uuid get_iid () const =0
 Returns the interface ID of the most derived interface. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0xca097e3a, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::Interface_declare< 0x1bb2be0f, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::Interface_declare< 0x2e5f84bc, ... >
typedef Interface_declare< id1, ... > Self
 Own type. More...
 
typedef Uuid_t< id1, ... > IID
 Declares the interface ID (IID) of this interface. More...
 
- Public Types inherited from mi::base::IInterface
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> IID
 Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0xca097e3a, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x1bb2be0f, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x2e5f84bc, ... >
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 
- Static Public Member Functions inherited from mi::base::IInterface
static bool compare_iid (const Uuid &iid)
 Compares the interface ID iid against the interface ID of this interface. More...
 

Detailed 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.

Member Function Documentation

 clear()

virtual void mi::IMap::clear ( )
pure virtual

Removes all keys and their associated values from the map.

 empty()

virtual bool mi::IMap::empty ( ) const
pure virtual

Checks whether the map is empty.

Equivalent to get_length() == 0.

 erase()

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

 get_length()

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.

Implements mi::IData_collection.

 insert()

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.