Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

xmlUtil::IdKey Class Reference

IdKey is a compressed, sortable version of an identifier which may be used as a key for a map. More...

#include <IdKey.h>

List of all members.

Public Methods

 IdKey (const Identifier id)
 Construct an IdKey from an Identifier. More...

 IdKey (const std::deque< unsigned int > id)
 Construct an IdKey from a deque. More...

 IdKey ()
 ~IdKey ()

Private Types

typedef std::vector< unsigned
int >::const_iterator 
KeyIt

Private Methods

template<class Container> void fillFrom (const Container &con)
 template function which does the actual work of building the new IdKey. More...


Private Attributes

std::vector< unsigned int > m_key
 Compressed identifier is stored in /a m_key. More...


Friends

class ltkey


Detailed Description

IdKey is a compressed, sortable version of an identifier which may be used as a key for a map.

Definition at line 15 of file IdKey.h.


Member Typedef Documentation

typedef std::vector<unsigned int>::const_iterator xmlUtil::IdKey::KeyIt [private]
 

Definition at line 48 of file IdKey.h.


Constructor & Destructor Documentation

xmlUtil::IdKey::IdKey const Identifier    id
 

Construct an IdKey from an Identifier.

Definition at line 12 of file IdKey.cxx.

References fillFrom().

00012                                   {
00013     fillFrom(id);
00014   }

xmlUtil::IdKey::IdKey const std::deque< unsigned int >    id
 

Construct an IdKey from a deque.

Definition at line 16 of file IdKey.cxx.

References fillFrom().

00016                                               {
00017     fillFrom(id);
00018   }

xmlUtil::IdKey::IdKey   [inline]
 

Definition at line 23 of file IdKey.h.

00023 {}

xmlUtil::IdKey::~IdKey  
 

Definition at line 83 of file IdKey.cxx.

References m_key.

00083 {m_key.clear(); m_key.resize(0);}


Member Function Documentation

template<class Container>
void xmlUtil::IdKey::fillFrom const Container &    con [private]
 

template function which does the actual work of building the new IdKey.

In principle it could be instantiated for any container whose value type is unsigned int.

Definition at line 24 of file IdKey.cxx.

References m_key.

Referenced by IdKey().

00024                                            {
00025 
00026     typename Container::const_iterator start  = con.begin();
00027     typename Container::const_iterator stop  = con.end();
00028 
00029     const unsigned int inSize = con.size();
00030 
00031     m_key.reserve((inSize + 3) / 4);
00032     unsigned int out = 0;
00033     unsigned int iByte = 0;
00034 
00035     typename Container::const_iterator inIt = start;
00036 
00037     for (; inIt != stop; ++inIt) {
00038       unsigned int cur = *inIt + 1;
00039 
00040       if (cur > maxVal) {
00041         // not allowed
00042         assert(maxVal > cur);
00043       }
00044       out *= moveLeft;  
00045       out += cur; 
00046       iByte++; 
00047       if (iByte == 4) {  // store the word; re-init for next word
00048         m_key.push_back(out);
00049         out = 0;
00050         iByte = 0;
00051       }
00052     }
00053 
00054     if (iByte) {
00055       while (iByte < 4) {
00056         out *= moveLeft;
00057         iByte++;
00058       }
00059       m_key.push_back(out);
00060     }
00061   }


Friends And Related Function Documentation

friend class ltkey [friend]
 

Definition at line 39 of file IdKey.h.


Member Data Documentation

std::vector<unsigned int> xmlUtil::IdKey::m_key [private]
 

Compressed identifier is stored in /a m_key.

Definition at line 50 of file IdKey.h.

Referenced by fillFrom(), and ~IdKey().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:02:50 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001