office-gobmx/soltools/ldump/hashtbl.hxx
Jens-Heiner Rechtien fdb5c29723 INTEGRATION: CWS warnings01 (1.1.146); FILE MERGED
2005/09/23 02:15:06 sb 1.1.146.2: RESYNC: (1.1-1.2); FILE MERGED
2005/09/02 14:57:36 sb 1.1.146.1: #i53898# Made code warning-free.
2006-06-20 04:08:26 +00:00

119 lines
3.2 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: hashtbl.hxx,v $
*
* $Revision: 1.3 $
*
* last change: $Author: hr $ $Date: 2006-06-20 05:08:26 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#ifndef _HASHTBL_HXX
#define _HASHTBL_HXX
// ADT hash table
//
// Invariante:
// 1. m_lElem < m_lSize
// 2. die Elemente in m_Array wurden double-hashed erzeugt
//
class HashItem;
class HashTable
{
unsigned long m_lSize;
unsigned long m_lElem;
HashItem *m_pData;
double m_dMaxLoadFactor;
double m_dGrowFactor;
bool m_bOwner;
unsigned long Hash(const char *cKey) const;
unsigned long DHash(const char *cKey , unsigned long lHash) const;
unsigned long Probe(unsigned long lPos) const;
HashItem* FindPos(const char *cKey) const;
void SmartGrow();
double CalcLoadFactor() const;
protected:
friend class HashTableIterator;
virtual void OnDeleteObject(void* pObject);
void* GetObjectAt(unsigned long lPos) const;
// Default-Werte
public:
static double m_defMaxLoadFactor;
static double m_defDefGrowFactor;
public:
HashTable
(
unsigned long lSize,
bool bOwner,
double dMaxLoadFactor = HashTable::m_defMaxLoadFactor /* 0.8 */,
double dGrowFactor = HashTable::m_defDefGrowFactor /* 2.0 */
);
virtual ~HashTable();
bool IsFull() const;
unsigned long GetSize() const { return m_lSize; }
void* Find (const char *cKey ) const;
bool Insert (const char *cKey , void* pObject);
void* Delete (const char *cKey);
};
// ADT hash table iterator
//
// Invariante: 0 <= m_lAt < m_aTable.GetCount()
//
class HashTableIterator
{
unsigned long m_lAt;
HashTable const& m_aTable;
void operator =(HashTableIterator &); // not defined
void* FindValidObject(bool bForward);
protected:
void* GetFirst(); // Interation _ohne_ Sortierung
void* GetNext();
void* GetLast();
void* GetPrev();
public:
HashTableIterator(HashTable const&);
};
#endif // _HASHTBL_HXX