casacore
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
casacore::OrderedMap< key, value > Class Template Reference

Map with keys ordered. More...

#include <OrderedMap.h>

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 key, class value>
class casacore::OrderedMap< key, value >

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 42 of file OrderedMap.h.

Member Enumeration Documentation

◆ anonymous enum

template<class key, class value>
anonymous enum
Enumerator
OrderedMapVersion 

Definition at line 285 of file OrderedMap.h.

Constructor & Destructor Documentation

◆ OrderedMap() [1/3]

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

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

Definition at line 245 of file OrderedMap.h.

◆ OrderedMap() [2/3]

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

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

Definition at line 250 of file OrderedMap.h.

◆ OrderedMap() [3/3]

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

Creates a map from another one; use copy semantics.

Definition at line 255 of file OrderedMap.h.

◆ ~OrderedMap()

template<class key, class value>
casacore::OrderedMap< key, value >::~OrderedMap ( )

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

the letter contains the guts.

Member Function Documentation

◆ getKey() [1/2]

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

Definition at line 228 of file OrderedMap.h.

◆ getKey() [2/2]

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

Definition at line 234 of file OrderedMap.h.

◆ getVal() [1/2]

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

Definition at line 216 of file OrderedMap.h.

◆ getVal() [2/2]

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

Definition at line 222 of file OrderedMap.h.

◆ incr() [1/2]

template<class key, class value>
uInt casacore::OrderedMap< key, value >::incr ( ) const
inline

Get or set the Block allocation increment.

Definition at line 281 of file OrderedMap.h.

◆ incr() [2/2]

template<class key, class value>
uInt casacore::OrderedMap< key, value >::incr ( uInt  nri)
inline

Definition at line 282 of file OrderedMap.h.

◆ ntot()

template<class key, class value>
uInt casacore::OrderedMap< key, value >::ntot ( ) const
inline

Definition at line 275 of file OrderedMap.h.

◆ nused()

template<class key, class value>
uInt casacore::OrderedMap< key, value >::nused ( ) const
inline

Get the number of mappings.

Definition at line 274 of file OrderedMap.h.

◆ operator=()

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

Assigns this OrderedMap to another with copy semantics.

Definition at line 266 of file OrderedMap.h.

◆ throwgetKey()

template<class key, class value>
void casacore::OrderedMap< key, value >::throwgetKey ( uInt  ) const
protected

◆ throwgetValue()

template<class key, class value>
void casacore::OrderedMap< key, value >::throwgetValue ( uInt  ) const
protected

Friends And Related Function Documentation

◆ OrderedMapIterRep< key, value >

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

Definition at line 210 of file OrderedMap.h.


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