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 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)
 

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
 

Friends

class OrderedMapIterRep< key, value >
 

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

Member Enumeration Documentation

◆ anonymous enum

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

Definition at line 289 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 249 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 254 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 259 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 232 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 238 of file OrderedMap.h.

◆ getVal() [1/2]

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

Definition at line 220 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 226 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 285 of file OrderedMap.h.

◆ incr() [2/2]

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

Definition at line 286 of file OrderedMap.h.

◆ ntot()

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

Definition at line 279 of file OrderedMap.h.

◆ nused()

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

◆ 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 270 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 183 of file OrderedMap.h.


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