HashTableView< T, SUBCLASS > Struct Template Reference

#include <HashTableGeneric.h>

Inheritance diagram for HashTableView< T, SUBCLASS >:

Inheritance graph
[legend]
Collaboration diagram for HashTableView< T, SUBCLASS >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef T HitType
typedef const HitTypeiterator
typedef const HitTypeconst_iterator

Public Member Functions

 HashTableView (ostream &monitoringStream, string name, Allocator< HitType > &hitListAllocator, Allocator< PositionInHitList > &arrayAllocator)
virtual ~HashTableView ()
virtual void hashWords (SequenceAdapter &thisSeq, SequenceNumber seqNum)=0
virtual void countWords (SequenceAdapter &thisSeq)=0
virtual int getHitTypeSize (void) const
virtual char * getHitListStart (void) const
virtual void allocateHitList (unsigned long size)
virtual void loadHitList (unsigned long size)
virtual void saveHitList (void)
const_iterator begin (Word w) const
const_iterator last (Word w) const
const_iterator end (Word w) const
const int size (Word w) const
template<class HITLIST>
void matchWord (Word queryWord, HITLIST &hitsFound, int baseOffset=0) const
template<class HITLIST>
void matchWord (const WordSequence &queryWords, HITLIST &hitsFound, int baseOffset=0) const

Protected Attributes

HitTypepHitListForAllWords_
Allocator< HitType > * pHitListAllocator_

Private Member Functions

 HashTableView (const HashTableView &)
HashTableViewoperator= (const HashTableView &)

Friends

class HashTableFactory

Detailed Description

template<typename T, class SUBCLASS>
struct HashTableView< T, SUBCLASS >

Definition at line 499 of file HashTableGeneric.h.


Member Typedef Documentation

template<typename T, class SUBCLASS>
typedef T HashTableView< T, SUBCLASS >::HitType

Definition at line 506 of file HashTableGeneric.h.

template<typename T, class SUBCLASS>
typedef const HitType* HashTableView< T, SUBCLASS >::iterator

Definition at line 563 of file HashTableGeneric.h.

template<typename T, class SUBCLASS>
typedef const HitType* HashTableView< T, SUBCLASS >::const_iterator

Definition at line 564 of file HashTableGeneric.h.


Constructor & Destructor Documentation

template<typename T, class SUBCLASS>
HashTableView< T, SUBCLASS >::HashTableView ( ostream &  monitoringStream,
string  name,
Allocator< HitType > &  hitListAllocator,
Allocator< PositionInHitList > &  arrayAllocator 
) [inline]

Definition at line 513 of file HashTableGeneric.h.

00516                                                                 :
00517   HashTableGeneric
00518   ( monitoringStream, name, arrayAllocator )
00519     {
00520       pHitListAllocator_ =  hitListAllocator.clone
00521         (&pHitListForAllWords_, name+(string)".body", monitoringStream_ );
00522       //      pHitListAllocator_->link(&pHitListForAllWords_,name_+(string)".body");
00523     }

template<typename T, class SUBCLASS>
virtual HashTableView< T, SUBCLASS >::~HashTableView (  )  [inline, virtual]

Definition at line 529 of file HashTableGeneric.h.

00530   { 
00531     monitoringStream_ << "destructing HashTableView ...\n";
00532     if ( isInitialized_ )
00533     {
00534       monitoringStream_ << "... deallocating memory\n";
00535       //      pHitListAllocator_->deallocate();
00536       delete pHitListAllocator_; // also deallocs hit list
00537       //      delete [] pHitListForAllWords_; 
00538     } // ~if 
00539     else 
00540     {
00541       monitoringStream_ 
00542       << "... never initialized, no memory deallocation required\n";
00543     } // ~else
00544   } // destructor

template<typename T, class SUBCLASS>
HashTableView< T, SUBCLASS >::HashTableView ( const HashTableView< T, SUBCLASS > &   )  [private]


Member Function Documentation

template<typename T, class SUBCLASS>
virtual void HashTableView< T, SUBCLASS >::hashWords ( SequenceAdapter thisSeq,
SequenceNumber  seqNum 
) [pure virtual]

Implements HashTableGeneric.

Implemented in HashTable, and HashTablePacked.

template<typename T, class SUBCLASS>
virtual void HashTableView< T, SUBCLASS >::countWords ( SequenceAdapter thisSeq  )  [pure virtual]

Implements HashTableGeneric.

Implemented in HashTable, HashTablePacked, and HashTableTest.

template<typename T, class SUBCLASS>
virtual int HashTableView< T, SUBCLASS >::getHitTypeSize ( void   )  const [inline, virtual]

Implements HashTableGeneric.

Definition at line 566 of file HashTableGeneric.h.

00567   {
00568     return sizeof(HitType);
00569   }

template<typename T, class SUBCLASS>
virtual char* HashTableView< T, SUBCLASS >::getHitListStart ( void   )  const [inline, virtual]

Implements HashTableGeneric.

Definition at line 571 of file HashTableGeneric.h.

00572   {
00573     return (char*) pHitListForAllWords_;
00574   }

template<typename T, class SUBCLASS>
virtual void HashTableView< T, SUBCLASS >::allocateHitList ( unsigned long  size  )  [inline, virtual]

Implements HashTableGeneric.

Definition at line 576 of file HashTableGeneric.h.

00577   {
00578     //    pHitListForAllWords_=new HitType[size];
00579     pHitListAllocator_->allocate(size);
00580   }

template<typename T, class SUBCLASS>
virtual void HashTableView< T, SUBCLASS >::loadHitList ( unsigned long  size  )  [inline, virtual]

Implements HashTableGeneric.

Reimplemented in HashTablePacked.

Definition at line 582 of file HashTableGeneric.h.

Referenced by HashTablePacked::loadHitList().

00583   {
00584     pHitListAllocator_->load(size);
00585   }

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
virtual void HashTableView< T, SUBCLASS >::saveHitList ( void   )  [inline, virtual]

Implements HashTableGeneric.

Reimplemented in HashTablePacked.

Definition at line 587 of file HashTableGeneric.h.

Referenced by HashTablePacked::saveHitList().

00588   {
00589     pHitListAllocator_->save();
00590   }

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
const_iterator HashTableView< T, SUBCLASS >::begin ( Word  w  )  const [inline]

Definition at line 595 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::end(), HashTableView< PositionInDatabase, HashTable >::matchWord(), and HashTableView< PositionInDatabase, HashTable >::size().

00596   {
00597     return pHitListForAllWords_ +
00598       ( ( w == 0 ) ? 0 : pWordPositionInHitList_[ w - 1 ] );
00599   } // ~const_iterator begin( Word w ) const

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
const_iterator HashTableView< T, SUBCLASS >::last ( Word  w  )  const [inline]

Definition at line 601 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::end(), HashTableView< PositionInDatabase, HashTable >::matchWord(), and HashTableView< PositionInDatabase, HashTable >::size().

00602   {  
00603     return pHitListForAllWords_ + ( pWordPositionInHitList_[ w ] ); 
00604   } // ~const_iterator last( Word w ) const

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
const_iterator HashTableView< T, SUBCLASS >::end ( Word  w  )  const [inline]

Definition at line 606 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::matchWord().

00607   { 
00608     return( (size(w) > maxNumHits_) ? begin(w) : last(w) ); 
00609   } // ~const_iterator end( Word w ) const

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
const int HashTableView< T, SUBCLASS >::size ( Word  w  )  const [inline]

Definition at line 611 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::end(), and main().

00612   { 
00613     return( last(w) - begin(w) ); 
00614   } // ~const int size( Word w ) const

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
template<class HITLIST>
void HashTableView< T, SUBCLASS >::matchWord ( Word  queryWord,
HITLIST &  hitsFound,
int  baseOffset = 0 
) const [inline]

Definition at line 621 of file HashTableGeneric.h.

Referenced by doSearch(), main(), HashTableView< PositionInDatabase, HashTable >::matchWord(), HashTablePacked::matchWordStandard(), and HashTablePacked::matchWordSubstitute().

00622   {
00623     // About 1/2 the exec time of a matchWord is spent calling end()
00624     // so bung it in a const variable TC 12.3.2 
00625     //    for( iterator i( begin( queryWord ) ); 
00626     // i != end( queryWord ); i++ )
00627     if ((queryWord&gCursedWord)!=(Word)0) return;
00628     const_iterator endWord(end(queryWord));
00629     for( iterator i( begin( queryWord ) ); i != endWord; ++i )
00630     { 
00631       hitsFound.addHit
00632         ( *i, baseOffset );
00633     } // ~for i
00634 
00635   } // ~template< class HITLIST > void matchWord

Here is the caller graph for this function:

template<typename T, class SUBCLASS>
template<class HITLIST>
void HashTableView< T, SUBCLASS >::matchWord ( const WordSequence queryWords,
HITLIST &  hitsFound,
int  baseOffset = 0 
) const [inline]

Definition at line 640 of file HashTableGeneric.h.

00643   {
00644     //    printf("HashTable::matchWord (multiple)\n");
00645     if (queryWords.size()==0) return;
00646     
00647     // WordSequenceIterator last 
00648     //    = const_cast<WordSequenceIterator>(queryWords.end());
00649     //   last--; 
00650     WordSequence::const_iterator last(&queryWords.back());
00651 
00652     for ( WordSequence::const_iterator thisWord(queryWords.begin());
00653             thisWord != last ; ++thisWord )
00654     {
00655       matchWord( *thisWord, hitsFound, baseOffset );
00656       baseOffset += wordLength_;
00657     } // ~for
00658 
00659   } // ~  template< class HITLIST > void matchWord

template<typename T, class SUBCLASS>
HashTableView& HashTableView< T, SUBCLASS >::operator= ( const HashTableView< T, SUBCLASS > &   )  [private]


Friends And Related Function Documentation

template<typename T, class SUBCLASS>
friend class HashTableFactory [friend]

Reimplemented from HashTableGeneric.

Definition at line 502 of file HashTableGeneric.h.


Member Data Documentation

template<typename T, class SUBCLASS>
HitType* HashTableView< T, SUBCLASS >::pHitListForAllWords_ [protected]

Definition at line 685 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::begin(), HashTableView< PositionInDatabase, HashTable >::getHitListStart(), HashTableView< PositionInDatabase, HashTable >::HashTableView(), and HashTableView< PositionInDatabase, HashTable >::last().

template<typename T, class SUBCLASS>
Allocator<HitType>* HashTableView< T, SUBCLASS >::pHitListAllocator_ [protected]

Definition at line 686 of file HashTableGeneric.h.

Referenced by HashTableView< PositionInDatabase, HashTable >::allocateHitList(), HashTableView< PositionInDatabase, HashTable >::HashTableView(), HashTableView< PositionInDatabase, HashTable >::loadHitList(), HashTableView< PositionInDatabase, HashTable >::saveHitList(), and HashTableView< PositionInDatabase, HashTable >::~HashTableView().


The documentation for this struct was generated from the following file:
Generated on Fri Dec 21 13:17:45 2007 for ssaha by  doxygen 1.5.2