OOO330
[LibreOffice.git] / soltools / ldump / hashtbl.hxx
blob62d1f8e9120e6124a33fc16db3b64ef5225196eb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _HASHTBL_HXX
29 #define _HASHTBL_HXX
31 // ADT hash table
33 // Invariante:
34 // 1. m_lElem < m_lSize
35 // 2. die Elemente in m_Array wurden double-hashed erzeugt
37 class HashItem;
39 class HashTable
41 unsigned long m_lSize;
42 unsigned long m_lElem;
43 HashItem *m_pData;
44 double m_dMaxLoadFactor;
45 double m_dGrowFactor;
46 bool m_bOwner;
48 unsigned long Hash(const char *cKey) const;
49 unsigned long DHash(const char *cKey , unsigned long lHash) const;
50 unsigned long Probe(unsigned long lPos) const;
52 HashItem* FindPos(const char *cKey) const;
53 void SmartGrow();
54 double CalcLoadFactor() const;
56 protected:
57 friend class HashTableIterator;
59 virtual void OnDeleteObject(void* pObject);
61 void* GetObjectAt(unsigned long lPos) const;
63 // Default-Werte
64 public:
65 static double m_defMaxLoadFactor;
66 static double m_defDefGrowFactor;
68 public:
69 HashTable
71 unsigned long lSize,
72 bool bOwner,
73 double dMaxLoadFactor = HashTable::m_defMaxLoadFactor /* 0.8 */,
74 double dGrowFactor = HashTable::m_defDefGrowFactor /* 2.0 */
77 virtual ~HashTable();
79 bool IsFull() const;
80 unsigned long GetSize() const { return m_lSize; }
82 void* Find (const char *cKey ) const;
83 bool Insert (const char *cKey , void* pObject);
84 void* Delete (const char *cKey);
87 // ADT hash table iterator
89 // Invariante: 0 <= m_lAt < m_aTable.GetCount()
91 class HashTableIterator
93 unsigned long m_lAt;
94 HashTable const& m_aTable;
96 void operator =(HashTableIterator &); // not defined
98 void* FindValidObject(bool bForward);
100 protected:
101 void* GetFirst(); // Interation _ohne_ Sortierung
102 void* GetNext();
103 void* GetLast();
104 void* GetPrev();
106 public:
107 HashTableIterator(HashTable const&);
110 #endif // _HASHTBL_HXX