1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hashtbl.hxx,v $
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 ************************************************************************/
37 // 1. m_lElem < m_lSize
38 // 2. die Elemente in m_Array wurden double-hashed erzeugt
44 unsigned long m_lSize
;
45 unsigned long m_lElem
;
47 double m_dMaxLoadFactor
;
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;
57 double CalcLoadFactor() const;
60 friend class HashTableIterator
;
62 virtual void OnDeleteObject(void* pObject
);
64 void* GetObjectAt(unsigned long lPos
) const;
68 static double m_defMaxLoadFactor
;
69 static double m_defDefGrowFactor
;
76 double dMaxLoadFactor
= HashTable::m_defMaxLoadFactor
/* 0.8 */,
77 double dGrowFactor
= HashTable::m_defDefGrowFactor
/* 2.0 */
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
97 HashTable
const& m_aTable
;
99 void operator =(HashTableIterator
&); // not defined
101 void* FindValidObject(bool bForward
);
104 void* GetFirst(); // Interation _ohne_ Sortierung
110 HashTableIterator(HashTable
const&);
113 #endif // _HASHTBL_HXX