casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
casacore::OrderedMap< t, v > Class Template Reference

Map with keys ordered. More...

#include <OrderedMap.h>

Inheritance diagram for casacore::OrderedMap< t, v >:
casacore::Map< key, value >

Public Types

enum  { OrderedMapVersion }
 
- Public Types inherited from casacore::Map< key, value >
enum  { MapVersion }
 

Public Member Functions

 OrderedMap (const value &dflt, uInt size)
 Creates a map with the specified default value, "value", and the internal block size. More...
 
 OrderedMap (const value &dflt)
 Creates a map with the specified default value, "value". More...
 
 OrderedMap (const OrderedMap< key, value > &other)
 Creates a map from another one; use copy semantics. More...
 
 ~OrderedMap ()
 Does nothing, the destruction is taken care of in the base class, i.e. More...
 
OrderedMap< key, value > & operator= (const OrderedMap< key, value > &other)
 Assigns this OrderedMap to another with copy semantics. More...
 
uInt nused () const
 Get the number of mappings. More...
 
uInt ntot () const
 
uInt incr () const
 Get or set the Block allocation increment. More...
 
uInt incr (uInt nri)
 
- Public Member Functions inherited from casacore::Map< key, value >
valueoperator() (const key &ky)
 This is the mapping function which maps keys to values. More...
 
const valueoperator() (const key &ky) const
 
valuedefaultVal ()
 Returns the default value for the Map. More...
 
const valuedefaultVal () const
 
const valueisDefined (const key &k) const
 Returns a non-zero value if a mapping is defined for the key parameter. More...
 
valueisDefined (const key &k)
 
uInt ndefined () const
 Returns the number of user defined mappings. More...
 
valuedefine (const key &k, const value &v)
 These functions allow for the definition and removal of key/value relations. More...
 
void remove (const key &k)
 
void clear ()
 Clear all of the mappings. More...
 
MapIterRep< key, value > * getRep () const
 Returns the iterator rep appropriate for this particular Map. More...
 
 Map (const Map< key, value > &m)
 This copy constructor will, for the moment, be the only way to create a map. More...
 
 Map (const Map< key, value > *m)
 
Map< key, value > & operator= (const Map< key, value > &)
 
Map< key, value > & operator= (const Map< key, value > *)
 
virtual ~Map ()
 
ConstMapIter< key, value > * getIter () const
 

Protected Member Functions

void throwgetKey (uInt) const
 
void throwgetValue (uInt) const
 
valuegetVal (uInt inx)
 
const valuegetVal (uInt inx) const
 
key & getKey (uInt inx)
 
const key & getKey (uInt inx) const
 
- Protected Member Functions inherited from casacore::Map< key, value >
 Map (MapRep< key, value > *nRep)
 Used by derived classes. More...
 
void SetRep (MapRep< key, value > *st)
 Used the set the representation. More...
 

Friends

class OrderedMapIterRep< key, value >
 

Additional Inherited Members

- Protected Attributes inherited from casacore::Map< key, value >
MapRep< key, value > * Rep
 

Detailed Description

template<class t, class v>
class casacore::OrderedMap< t, v >

Map with keys ordered.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

OrderedMap<key,value> is a template class derived from Map. It is similar to ListMap, but the keys are kept in order and they have to be unique.

It uses a Block to store an array of pointers to the keys and the associated values. The keys and values themselves are stored on the heap. The keys are kept in order to allow a binary search through the keys for rapid access.

This is one (simple) implementation of an ordered map. It is not suitable for large arrays of keys, since the overhead of keeping the keys in order would get too big. For large arrays a red-black tree implementation would be better.

Exceptions are raised when new[] is failing, when the next() getKey() or getValue() function is failing or when a duplicate key is defined.

The AipsIO >> and << operators are defined in <aips/OrdMapIO.h>.

Definition at line 46 of file OrderedMap.h.

Member Enumeration Documentation

template<class t, class v>
anonymous enum
Enumerator
OrderedMapVersion 

Definition at line 289 of file OrderedMap.h.

Constructor & Destructor Documentation

template<class t, class v>
casacore::OrderedMap< t, v >::OrderedMap ( const value dflt,
uInt  size 
)
inline

Creates a map with the specified default value, "value", and the internal block size.

Definition at line 249 of file OrderedMap.h.

template<class t, class v>
casacore::OrderedMap< t, v >::OrderedMap ( const value dflt)
inlineexplicit

Creates a map with the specified default value, "value".

Definition at line 254 of file OrderedMap.h.

template<class t, class v>
casacore::OrderedMap< t, v >::OrderedMap ( const OrderedMap< key, value > &  other)
inline

Creates a map from another one; use copy semantics.

Definition at line 259 of file OrderedMap.h.

template<class t, class v>
casacore::OrderedMap< t, v >::~OrderedMap ( )

Does nothing, the destruction is taken care of in the base class, i.e.

the letter contains the guts.

Member Function Documentation

template<class t, class v>
key& casacore::OrderedMap< t, v >::getKey ( uInt  inx)
inlineprotected

Definition at line 232 of file OrderedMap.h.

template<class t, class v>
const key& casacore::OrderedMap< t, v >::getKey ( uInt  inx) const
inlineprotected

Definition at line 238 of file OrderedMap.h.

template<class t, class v>
value& casacore::OrderedMap< t, v >::getVal ( uInt  inx)
inlineprotected

Definition at line 220 of file OrderedMap.h.

template<class t, class v>
const value& casacore::OrderedMap< t, v >::getVal ( uInt  inx) const
inlineprotected

Definition at line 226 of file OrderedMap.h.

template<class t, class v>
uInt casacore::OrderedMap< t, v >::incr ( ) const
inline

Get or set the Block allocation increment.

Definition at line 285 of file OrderedMap.h.

template<class t, class v>
uInt casacore::OrderedMap< t, v >::incr ( uInt  nri)
inline

Definition at line 286 of file OrderedMap.h.

template<class t, class v>
uInt casacore::OrderedMap< t, v >::ntot ( ) const
inline

Definition at line 279 of file OrderedMap.h.

template<class t, class v>
uInt casacore::OrderedMap< t, v >::nused ( ) const
inline

Get the number of mappings.

Definition at line 278 of file OrderedMap.h.

Referenced by casacore::OrderedMap< key, value >::getKey(), and casacore::OrderedMap< key, value >::getVal().

template<class t, class v>
OrderedMap<key,value>& casacore::OrderedMap< t, v >::operator= ( const OrderedMap< key, value > &  other)
inline

Assigns this OrderedMap to another with copy semantics.

Definition at line 270 of file OrderedMap.h.

template<class t, class v>
void casacore::OrderedMap< t, v >::throwgetKey ( uInt  ) const
protected
template<class t, class v>
void casacore::OrderedMap< t, v >::throwgetValue ( uInt  ) const
protected

Friends And Related Function Documentation

template<class t, class v>
friend class OrderedMapIterRep< key, value >
friend

Definition at line 214 of file OrderedMap.h.


The documentation for this class was generated from the following file: