Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / soltools / ldump / hashtbl.hxx
blobb3aa621dcb21b3bd251e23377a7af2bfa7bf3431
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _HASHTBL_HXX
30 #define _HASHTBL_HXX
32 // ADT hash table
34 // Invariante:
35 // 1. m_lElem < m_lSize
36 // 2. die Elemente in m_Array wurden double-hashed erzeugt
38 class HashItem;
40 class HashTable
42 unsigned long m_lSize;
43 unsigned long m_lElem;
44 HashItem *m_pData;
45 double m_dMaxLoadFactor;
46 double m_dGrowFactor;
47 bool m_bOwner;
49 unsigned long Hash(const char *cKey) const;
50 unsigned long DHash(const char *cKey , unsigned long lHash) const;
51 unsigned long Probe(unsigned long lPos) const;
53 HashItem* FindPos(const char *cKey) const;
54 void SmartGrow();
55 double CalcLoadFactor() const;
57 protected:
58 friend class HashTableIterator;
60 virtual void OnDeleteObject(void* pObject);
62 void* GetObjectAt(unsigned long lPos) const;
64 // Default-Werte
65 public:
66 static double m_defMaxLoadFactor;
67 static double m_defDefGrowFactor;
69 public:
70 HashTable
72 unsigned long lSize,
73 bool bOwner,
74 double dMaxLoadFactor = HashTable::m_defMaxLoadFactor /* 0.8 */,
75 double dGrowFactor = HashTable::m_defDefGrowFactor /* 2.0 */
78 virtual ~HashTable();
80 bool IsFull() const;
81 unsigned long GetSize() const { return m_lSize; }
83 void* Find (const char *cKey ) const;
84 bool Insert (const char *cKey , void* pObject);
85 void* Delete (const char *cKey);
88 // ADT hash table iterator
90 // Invariante: 0 <= m_lAt < m_aTable.GetCount()
92 class HashTableIterator
94 unsigned long m_lAt;
95 HashTable const& m_aTable;
97 void operator =(HashTableIterator &); // not defined
99 void* FindValidObject(bool bForward);
101 protected:
102 void* GetFirst(); // Interation _ohne_ Sortierung
103 void* GetNext();
104 void* GetLast();
105 void* GetPrev();
107 public:
108 HashTableIterator(HashTable const&);
111 #endif // _HASHTBL_HXX
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */