ListMap.h

Classes

ListMapRep -- Representation of a ListMap class (full description)
ListMap -- Map with list ordering/operations (full description)
ListMapIterRep -- ListMap iterator "letter" (full description)

template<class key, class value> class ListMapRep : public MapRep<key,value>

Types

enum DefineOrder

Append
Prepend
Undefined

enum

ListMapRepVersion = 1

Interface

Public Members
ListMapRep(const value &dflt) : dflt<key,value>(dflt), list(new key<list<key,value> >,True), deforder(Undefined)
ListMapRep(const value &dflt, dflt InOrder) : MapRep<key,value>(dflt), list(new MapRep<key<key,value> >,True), deforder(InOrder)
value *isDefined(const key &)
const value *isDefined(const key &) const
uInt ndefined() const
value &define(const key &k, const value &v)
void remove(const key &)
void clear()
MapIterRep<key,value> *getRep(value<key,value> *) const
MapRep<key,value> *Clone() const
DefineOrder getOrder() const
void setOrder(DefineOrder OR)

Description

Review Status

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

Member Description

enum DefineOrder

ListMapRep(const value &dflt) : dflt<key,value>(dflt), list(new key<list<key,value> >,True), deforder(Undefined)

Creates a map with a particular default value

+grp

ListMapRep(const value &dflt, dflt InOrder) : MapRep<key,value>(dflt), list(new MapRep<key<key,value> >,True), deforder(InOrder)

value *isDefined(const key &)

-grp

These functions check to see if a mapping is defined between the specified key and some value. If one is, a pointer to the value is returned, otherwise 0 is returned.

+grp

const value *isDefined(const key &) const

uInt ndefined() const

-grp

Returns the number of user defined mappings

value &define(const key &k, const value &v)

Defines a mapping (ie. create a key value mapping)

void remove(const key &)

Undefines a mapping (ie. remove a key value mapping).

void clear()

Clear all of the mappings.

MapIterRep<key,value> *getRep(value<key,value> *) const

MapRep<key,value> *Clone() const

DefineOrder getOrder() const

Set/Get the insertion order

+grp

void setOrder(DefineOrder OR)

enum

-grp


template<class key, class value> class ListMap : public Map<key,value>

Types

enum DefineOrder

Append
Prepend
Undefined

enum

ListMapVersion = 1

Interface

Protected Members
ListIter<OrderedPair<key,value> > &list()
Public Members
explicit ListMap(const value &dflt) : Map<key,value>(new ListMapRep<key,value>(dflt))
ListMap(const value &dflt, dflt InOrder) : Map<key,value>(new ListMapRep<key,value>(dflt, InOrder == Append ? ListMapRep<key,value>::Append : InOrder == Prepend ? ListMapRep<key,value>::Prepend : ListMapRep<key,value>::Undefined))
ListMap(const ListMap<key,value> &other) : Map<key,value>(other.Rep->Clone())
ListMap<key,value> &operator=(const ListMap<key,value>&other)
DefineOrder getOrder() const
void setOrder(DefineOrder OR)

Description

Review Status

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

This is one possible implementation of the Map class. It uses a linked list to implement an associative array. Other likely implementations are hashed, and binary tree. It can be used as follows: ListMap map(0); map.define(3,4); map.define(5,6); map.define(7,8); cout << map(3) << endl; cout << map(7) << endl; map(7) = 78;

Member Description

ListIter<OrderedPair<key,value> > &list()

enum DefineOrder

explicit ListMap(const value &dflt) : Map<key,value>(new ListMapRep<key,value>(dflt))

Creates a map with a particular default value

+grp

ListMap(const value &dflt, dflt InOrder) : Map<key,value>(new ListMapRep<key,value>(dflt, InOrder == Append ? ListMapRep<key,value>::Append : InOrder == Prepend ? ListMapRep<key,value>::Prepend : ListMapRep<key,value>::Undefined))

ListMap(const ListMap<key,value> &other) : Map<key,value>(other.Rep->Clone())

-grp

Creates a ListMap from an existing one (copy semantics).

ListMap<key,value> &operator=(const ListMap<key,value>&other)

Assigns one list map to another (copy semantics).

DefineOrder getOrder() const

Set/Get the insertion order

+grp

void setOrder(DefineOrder OR)

enum

-grp


template<class key, class value> class ListMapIterRep : virtual public MapIterRep<key,value>

Types

enum

ListMapIterRepVersion = 1

Interface

Bool isValid() const
Bool atEnd() const
Bool atStart() const
void toStart()
void operator++()
void operator++(int)
const key &getKey() const
const value &getVal() const
value &getVal()
MapIterRep<key,value> *Clone()
ListMapIterRep(ListMap<key,value> *st) : MapIterRep<key,value>(st), listp(st->list())
ListMapIterRep(ListMap<key,value> &st) : MapIterRep<key,value>(st), listp(st.list())

Description

Review Status

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

This is the "letter" which when paired (Const)MapIter "envelope" allows traversal of "ListMap"s.

Member Description

Bool isValid() const

Checks to see if the iterator is in a valid state.

Bool atEnd() const

Checks to see if the iterator is at one of the map extremes, "atEnd()" or "atStart()".

+grp

Bool atStart() const

void toStart()

-grp

Move the iterator to the beginning of the Map.

void operator++()

Advance the iterator to the next key.

+grp

void operator++(int)

const key &getKey() const

-grp

Retrieve the key at the current iterator position.

const value &getVal() const

Retrieve the value at the current iterator position.

+grp

value &getVal()

MapIterRep<key,value> *Clone()

-grp

ListMapIterRep(ListMap<key,value> *st) : MapIterRep<key,value>(st), listp(st->list())

These constructors allow a ListMapIter to be constructed from a ListMap.

+grp

ListMapIterRep(ListMap<key,value> &st) : MapIterRep<key,value>(st), listp(st.list())

enum

-grp