Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AMOS::IDMap_t Class Reference

An IID/EID double hash for mapping IIDs and EIDs to BIDs. More...

#include <IDMap_AMOS.hh>

Inheritance diagram for AMOS::IDMap_t:

Inheritance graph
[legend]
Collaboration diagram for AMOS::IDMap_t:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 IDMap_t ()
 Contstructs an empty IDMap_t object.
 IDMap_t (Size_t buckets)
 Contstructs an empty IDMap_t object.
 IDMap_t (const IDMap_t &source)
 Copy constructor.
 ~IDMap_t ()
 Destroys a IDMap_t object.
const_iterator begin () const
 Returns an IDMap_t::const_iterator to the beginning of the map.
const_iterator end () const
 Returns an IDMap_t::const_iterator to the end of the map.
void clear ()
 Clears all object data.
void concat (const IDMap_t &source)
 Concatenate another IDMap onto this one.
bool empty () const
 Returns true if the map is empty.
bool exists (const std::string &key) const
 Check if a certain EID exists in the map.
bool exists (ID_t key) const
 Check if a certain IID exists in the map.
Size_t getBuckets () const
 Returns the current number of buckets being used.
virtual NCode_t getNCode () const
 Get the AMOS NCode type identifier.
Size_t getSize () const
 Get the number of value triples in the map.
NCode_t getType () const
 The type of IDs stored in the map.
const HashTriple_tinsert (ID_t iid, const std::string &eid, ID_t bid=NULL_ID)
 Insert a new EID/IID keyed value into the map.
const HashTriple_tinsert (const std::string &eid, ID_t bid=NULL_ID)
 Insert a new EID keyed value into the map.
const HashTriple_tinsert (ID_t iid, ID_t bid=NULL_ID)
 Insert a new IID keyed value into the map.
ID_t lookupBID (const std::string &key) const
 Lookup the BID associated with an EID key.
ID_t lookupBID (ID_t key) const
 Lookup the BID associated with an IID key.
const std::string & lookupEID (ID_t key) const
 Lookup the EID associated with an IID key.
ID_t lookupIID (const std::string &key) const
 Lookup the IID associated with an EID key.
IDMap_toperator= (const IDMap_t &source)
 Assignment (copy) operator.
virtual void readMessage (const Message_t &msg)
 Reads in data from a Message object.
void remove (ID_t key)
 Remove an existing value triple from the map by IID key.
void remove (const std::string &key)
 Remove an existing value triple from the map by EID key.
void resize (Size_t min)
 Resize the hash table.
virtual void writeMessage (Message_t &msg) const
 Writes data to a Message object.
void read (std::istream &in)
 Read a tab-delimited IDMap record.
void setType (NCode_t type)
 Set the type of the mapped IDs.
void write (std::ostream &out) const
 Write a tab-delimited IDMap record.

Static Public Attributes

const NCode_t NCODE = M_IDMAP
 The NCode type identifier for this object.

Detailed Description

An IID/EID double hash for mapping IIDs and EIDs to BIDs.

A double hash of IIDs and EIDs to each other and BIDs. Users may lookup an EID or BID via an IID, or may lookup an IID or BID via an EID.

A quick review of the identifier nomenclature: BID is a bank index, EID is an external ID, and IID is an internal AMOS ID. BIDs are physical bank indices; useful only for debugging purposes. IIDs are interger IDs used by AMOS for object links and identification, e.g. retrieving an object from a bank. EIDs are string indentifiers of unlimited length, e.g. sequence names. The empty string is used as an equivalent for NULL EID.

Definition at line 36 of file IDMap_AMOS.hh.


Constructor & Destructor Documentation

AMOS::IDMap_t::IDMap_t  )  [inline]
 

Contstructs an empty IDMap_t object.

Definition at line 305 of file IDMap_AMOS.hh.

References AMOS::NULL_NCODE, and resize().

AMOS::IDMap_t::IDMap_t Size_t  buckets  )  [inline]
 

Contstructs an empty IDMap_t object.

Parameters:
buckets Minimum number of hash table buckets to start with
Definition at line 317 of file IDMap_AMOS.hh.

References AMOS::NULL_NCODE, resize(), and AMOS::Size_t.

AMOS::IDMap_t::IDMap_t const IDMap_t source  )  [inline]
 

Copy constructor.

Definition at line 327 of file IDMap_AMOS.hh.

References AMOS::NULL_NCODE.

AMOS::IDMap_t::~IDMap_t  )  [inline]
 

Destroys a IDMap_t object.

Definition at line 337 of file IDMap_AMOS.hh.

References clear().


Member Function Documentation

const_iterator AMOS::IDMap_t::begin  )  const [inline]
 

Returns an IDMap_t::const_iterator to the beginning of the map.

Constant iterator on all the HashTriple_t values in the map. Will go NULL when at end of list. Test for validity just as you would test a pointer: for ( myitr = mymap.begin( ); mitr; ++ mitr ) Definition at line 350 of file IDMap_AMOS.hh.

Referenced by clear(), concat(), AMOS::IDMap_t::const_iterator::const_iterator(), AMOS::IDMap_t::const_iterator::operator++(), resize(), write(), and writeMessage().

void IDMap_t::clear  ) 
 

Clears all object data.

Clears data, but does not resize the hash table.

Returns:
void
Definition at line 61 of file IDMap_AMOS.cc.

References begin(), end(), and AMOS::NULL_NCODE.

Referenced by operator=(), read(), readMessage(), resize(), writeMessage(), and ~IDMap_t().

void IDMap_t::concat const IDMap_t source  ) 
 

Concatenate another IDMap onto this one.

Has no effect if source is the same IDMap as this one.

Precondition:
The two IDMaps are entirely disjoint
Returns:
void
Definition at line 180 of file IDMap_AMOS.cc.

References begin(), end(), getSize(), insert(), and resize().

Referenced by operator=().

bool AMOS::IDMap_t::empty  )  const [inline]
 

Returns true if the map is empty.

Returns:
true if empty, else false
Definition at line 395 of file IDMap_AMOS.hh.

Referenced by AMOS::IDMap_t::const_iterator::const_iterator(), insert(), and remove().

const_iterator AMOS::IDMap_t::end  )  const [inline]
 

Returns an IDMap_t::const_iterator to the end of the map.

Constant iterator on all the HashTriple_t values in the map. Usage similar to STL iterators, i.e. for ( itr = map.begin( ); itr != map.end( ); ++ itr ) Definition at line 363 of file IDMap_AMOS.hh.

Referenced by clear(), concat(), AMOS::IDMap_t::const_iterator::operator++(), resize(), write(), and writeMessage().

bool AMOS::IDMap_t::exists ID_t  key  )  const [inline]
 

Check if a certain IID exists in the map.

Returns true if the IID exists, otherwise false. Will always return false if key is NULL_ID.

Parameters:
key The IID key to check
Returns:
true if key exists, otherwise false
Definition at line 426 of file IDMap_AMOS.hh.

References AMOS::ID_t.

bool AMOS::IDMap_t::exists const std::string &  key  )  const [inline]
 

Check if a certain EID exists in the map.

Returns true if the EID exists, otherwise false. Will always return false if key is NULL.

Parameters:
key The EID key to check
Returns:
true if key exists, otherwise false
Definition at line 410 of file IDMap_AMOS.hh.

Referenced by readMessage().

Size_t AMOS::IDMap_t::getBuckets  )  const [inline]
 

Returns the current number of buckets being used.

Returns:
The current number of buckets being used
Definition at line 438 of file IDMap_AMOS.hh.

References AMOS::Size_t.

Referenced by insert(), and resize().

virtual NCode_t AMOS::IDMap_t::getNCode  )  const [inline, virtual]
 

Get the AMOS NCode type identifier.

Returns:
The AMOS NCode type identifier

Implements AMOS::IMessagable_t.

Definition at line 445 of file IDMap_AMOS.hh.

References AMOS::NCode_t.

Size_t AMOS::IDMap_t::getSize  )  const [inline]
 

Get the number of value triples in the map.

Returns:
The number of value triples in the map
Definition at line 456 of file IDMap_AMOS.hh.

References AMOS::Size_t.

Referenced by concat().

NCode_t AMOS::IDMap_t::getType  )  const [inline]
 

The type of IDs stored in the map.

Returns:
The NCode of the IDs or NULL_NCODE if unset
Definition at line 467 of file IDMap_AMOS.hh.

References AMOS::NCode_t.

const HashTriple_t* AMOS::IDMap_t::insert ID_t  iid,
ID_t  bid = NULL_ID
[inline]
 

Insert a new IID keyed value into the map.

Inserts a new BID into the map via an IID key. Has no effect if IID is NULL_ID, but BID is permitted to be NULL_ID.

Parameters:
iid The IID key
bid The bank index value
Precondition:
The IID does not already exist in the map
Exceptions:
ArgumentException_t 
Returns:
void
Definition at line 527 of file IDMap_AMOS.hh.

References AMOS::ID_t, insert(), and AMOS::NULL_STRING.

const HashTriple_t* AMOS::IDMap_t::insert const std::string &  eid,
ID_t  bid = NULL_ID
[inline]
 

Insert a new EID keyed value into the map.

Inserts a new BID into the map via an EID key. Has no effect if EID is NULL, but BID is permitted to be NULL_ID.

Parameters:
eid The EID key
bid The bank index value
Precondition:
EID contains no newlines

The EID does not already exist in the map

Exceptions:
ArgumentException_t 
Returns:
void
Definition at line 509 of file IDMap_AMOS.hh.

References AMOS::ID_t, insert(), and AMOS::NULL_ID.

const IDMap_t::HashTriple_t * IDMap_t::insert ID_t  iid,
const std::string &  eid,
ID_t  bid = NULL_ID
 

Insert a new EID/IID keyed value into the map.

Inserts a new BID into the map via both an EID and IID key. Has no effect if *both* EID and IID are NULL, but *one* of them and BID are permitted to be NULL. If EID is NULL but IID is not, then a triple will be inserted into the map, keyed only by the IID. If IID is NULL but EID is not, then a triple will be inserted, keyed only by EID. If neither is NULL, then the triple will be keyed by both. If both are NULL, there is no effect.

Parameters:
iid The IID key
eid The EID key
bid The bank index value
Precondition:
The IID does not already exist in the map

The EID does not already exist in the map

Exceptions:
ArgumentException_t 
Returns:
Pointer to the inserted triple
Definition at line 194 of file IDMap_AMOS.cc.

References AMOS_THROW_ARGUMENT, empty(), getBuckets(), AMOS::ID_t, AMOS::NULL_ID, and resize().

Referenced by concat(), insert(), read(), and readMessage().

ID_t AMOS::IDMap_t::lookupBID ID_t  key  )  const [inline]
 

Lookup the BID associated with an IID key.

Note:
BID value is permitted to be NULL_ID, so returning NULL_ID does not guarantee that the IID key does not exist. NULL_ID will always be returned for a NULL_ID key.
Parameters:
key The IID key of the BID to lookup
Returns:
The BID of the lookup key or NULL_ID if key does not exist
Definition at line 562 of file IDMap_AMOS.hh.

References AMOS::ID_t, and AMOS::NULL_ID.

ID_t AMOS::IDMap_t::lookupBID const std::string &  key  )  const [inline]
 

Lookup the BID associated with an EID key.

Note:
BID value is permitted to be NULL_ID, so returning NULL_ID does not guarantee that the EID key does not exist. NULL_ID will always be returned for a NULL key.
Parameters:
key The EID key of the BID to lookup
Returns:
The BID of the lookup key or NULL_ID if key does not exist
Definition at line 543 of file IDMap_AMOS.hh.

References AMOS::ID_t, and AMOS::NULL_ID.

const std::string& AMOS::IDMap_t::lookupEID ID_t  key  )  const [inline]
 

Lookup the EID associated with an IID key.

Note:
EID value is permitted to be NULL, so returning the empty string does not guarantee that the IID key does not exist. The empty string will always be returned for a NULL_ID key.
Parameters:
key The IID key of the EID to lookup
Returns:
The EID of the lookup key or empty ('\0') if key does not exist
Definition at line 581 of file IDMap_AMOS.hh.

References AMOS::ID_t, and AMOS::NULL_STRING.

ID_t AMOS::IDMap_t::lookupIID const std::string &  key  )  const [inline]
 

Lookup the IID associated with an EID key.

Note:
IID value is permitted to be NULL_ID, so returning NULL_ID does not guarantee that the EID key does not exist. NULL_ID will always be returned for a NULL key.
Parameters:
key The EID key of the IID to lookup
Returns:
The IID of the lookup key or NULL_ID if key does not exist
Definition at line 600 of file IDMap_AMOS.hh.

References AMOS::ID_t, and AMOS::NULL_ID.

IDMap_t & IDMap_t::operator= const IDMap_t source  ) 
 

Assignment (copy) operator.

Simply clears the current map and calls insert on everything in source. Does not guarantee that getBuckets( ) will equal source.getBuckets( ) after the assignment. Throws an exception if copy failed due to corrupt source map.

Parameters:
source The map to copy
Exceptions:
ArgumentException_t 
Returns:
The resulting map object
Definition at line 480 of file IDMap_AMOS.cc.

References clear(), and concat().

void IDMap_t::read std::istream &  in  ) 
 

Read a tab-delimited IDMap record.

IDMap NCode and size listed on the first line separated by a single space, followed by one tab-delimited triple per line in the order: bid, iid, eid. One of the stream's error bits will be set on failure.

Parameters:
in The stream to read the IDMap from
Returns:
void
Definition at line 494 of file IDMap_AMOS.cc.

References clear(), AMOS::Encode(), AMOS::ID_t, insert(), resize(), and AMOS::Size_t.

void IDMap_t::readMessage const Message_t msg  )  [virtual]
 

Reads in data from a Message object.

Reads the data contained in a Message object and stores it in the Messagable object. Will not complain if incoming message is of the wrong type, will only try and suck out the fields it recognizes. All previous data in the Messagable object will be cleared or overwritten.

Parameters:
msg The Message to read from
Precondition:
The expected fields are formatted properly
Exceptions:
ArgumentException_t 
Returns:
void

Implements AMOS::IMessagable_t.

Definition at line 240 of file IDMap_AMOS.cc.

References AMOS_THROW_ARGUMENT, clear(), AMOS::Encode(), exists(), AMOS::F_MAP, AMOS::F_OBJECT, AMOS::F_SIZE, AMOS::ID_t, insert(), AMOS::NCODE_SIZE, resize(), and AMOS::Size_t.

void IDMap_t::remove const std::string &  key  ) 
 

Remove an existing value triple from the map by EID key.

Removes an existsing value triple from the map. Has no effect if the key does not exist or is NULL. If EID is associated with an IID, the IID key will also be removed.

Parameters:
key The EID key of the triple to remove
Returns:
void
Definition at line 340 of file IDMap_AMOS.cc.

References empty(), AMOS::ID_t, and AMOS::NULL_ID.

void IDMap_t::remove ID_t  key  ) 
 

Remove an existing value triple from the map by IID key.

Removes an existsing value triple from the map. Has no effect if the key does not exist or is NULL_ID. If IID is associated with an EID, the EID key will also be removed.

Parameters:
key The IID key of the triple to remove
Returns:
void
Definition at line 300 of file IDMap_AMOS.cc.

References empty(), AMOS::ID_t, and AMOS::NULL_ID.

void IDMap_t::resize Size_t  min  ) 
 

Resize the hash table.

This will cause the hash to reorganize itself and is not recommended as a frequent operation. If request is larger than max number of buckets the max number of buckets will be used. Otherwise, the resulting number of buckets is only guaranteed to be greater than request.

Number of buckets will automatically increase whenever an insert operation causes the number of elements to be >= than number of buckets.

Parameters:
min Minimum number of buckets to use
Returns:
void
Definition at line 380 of file IDMap_AMOS.cc.

References AMOS_THROW, begin(), clear(), end(), getBuckets(), AMOS::NCode_t, and AMOS::Size_t.

Referenced by concat(), IDMap_t(), insert(), read(), and readMessage().

void AMOS::IDMap_t::setType NCode_t  type  )  [inline]
 

Set the type of the mapped IDs.

Parameters:
type The NCode type of the mapped IDs
Returns:
void
Definition at line 694 of file IDMap_AMOS.hh.

References AMOS::NCode_t.

void IDMap_t::write std::ostream &  out  )  const
 

Write a tab-delimited IDMap record.

IDMap NCode and size listed on the first line separated by a single space, followed by one tab-delimited triple per line in the order: bid, iid, eid. One of the stream's error bits will be set on failure.

Parameters:
out The stream to write the IDMap to
Returns:
void
Definition at line 522 of file IDMap_AMOS.cc.

References begin(), AMOS::Decode(), end(), and AMOS::NL_CHAR.

void IDMap_t::writeMessage Message_t msg  )  const [virtual]
 

Writes data to a Message object.

Writes the data contained in a Messagable object to a Message object. All previous data in the Message will be cleared or overwritten.

Parameters:
msg The Message to write to
Returns:
void

Implements AMOS::IMessagable_t.

Definition at line 439 of file IDMap_AMOS.cc.

References begin(), clear(), AMOS::Decode(), end(), AMOS::F_MAP, AMOS::F_OBJECT, AMOS::F_SIZE, AMOS::NL_CHAR, AMOS::NULL_NCODE, and AMOS::NULL_STRING.


Member Data Documentation

const NCode_t IDMap_t::NCODE = M_IDMAP [static]
 

The NCode type identifier for this object.

Definition at line 56 of file IDMap_AMOS.cc.


The documentation for this class was generated from the following files:
Generated on Tue May 17 15:19:47 2005 for libAMOS by doxygen 1.3.8