update dev300-m58
[ooovba.git] / soltools / ldump / hashtbl.hxx
blobcb763e9ed85bbc965f02ca7e5436b9760e5b16c1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hashtbl.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _HASHTBL_HXX
32 #define _HASHTBL_HXX
34 // ADT hash table
36 // Invariante:
37 // 1. m_lElem < m_lSize
38 // 2. die Elemente in m_Array wurden double-hashed erzeugt
40 class HashItem;
42 class HashTable
44 unsigned long m_lSize;
45 unsigned long m_lElem;
46 HashItem *m_pData;
47 double m_dMaxLoadFactor;
48 double m_dGrowFactor;
49 bool m_bOwner;
51 unsigned long Hash(const char *cKey) const;
52 unsigned long DHash(const char *cKey , unsigned long lHash) const;
53 unsigned long Probe(unsigned long lPos) const;
55 HashItem* FindPos(const char *cKey) const;
56 void SmartGrow();
57 double CalcLoadFactor() const;
59 protected:
60 friend class HashTableIterator;
62 virtual void OnDeleteObject(void* pObject);
64 void* GetObjectAt(unsigned long lPos) const;
66 // Default-Werte
67 public:
68 static double m_defMaxLoadFactor;
69 static double m_defDefGrowFactor;
71 public:
72 HashTable
74 unsigned long lSize,
75 bool bOwner,
76 double dMaxLoadFactor = HashTable::m_defMaxLoadFactor /* 0.8 */,
77 double dGrowFactor = HashTable::m_defDefGrowFactor /* 2.0 */
80 virtual ~HashTable();
82 bool IsFull() const;
83 unsigned long GetSize() const { return m_lSize; }
85 void* Find (const char *cKey ) const;
86 bool Insert (const char *cKey , void* pObject);
87 void* Delete (const char *cKey);
90 // ADT hash table iterator
92 // Invariante: 0 <= m_lAt < m_aTable.GetCount()
94 class HashTableIterator
96 unsigned long m_lAt;
97 HashTable const& m_aTable;
99 void operator =(HashTableIterator &); // not defined
101 void* FindValidObject(bool bForward);
103 protected:
104 void* GetFirst(); // Interation _ohne_ Sortierung
105 void* GetNext();
106 void* GetLast();
107 void* GetPrev();
109 public:
110 HashTableIterator(HashTable const&);
113 #endif // _HASHTBL_HXX