build fix
[LibreOffice.git] / idl / inc / hash.hxx
bloba510fbd35a804044bed278ff185a38ca53ead6b8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_IDL_INC_HASH_HXX
21 #define INCLUDED_IDL_INC_HASH_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/ref.hxx>
25 #include <tools/solar.h>
26 #include <vector>
28 class SvHashTable
30 sal_uInt32 nMax; // size of hash-tabel
31 sal_uInt32 nFill; // elements in hash-tabel
32 sal_uInt32 lAsk; // number of requests
33 sal_uInt32 lTry; // number of tries
34 protected:
35 bool Test_Insert( const OString&, bool bInsert, sal_uInt32 * pInsertPos );
37 // compare element with entry
38 virtual bool equals( const OString& , sal_uInt32 ) const = 0;
39 // get hash value from subclass
40 virtual sal_uInt32 HashFunc( const OString& ) const = 0;
41 public:
42 SvHashTable( sal_uInt32 nMaxEntries );
43 virtual ~SvHashTable();
45 sal_uInt32 GetMax() const { return nMax; }
47 virtual bool IsEntry( sal_uInt32 ) const = 0;
50 class SvStringHashTable;
51 class SvStringHashEntry : public SvRefBase
53 friend class SvStringHashTable;
54 OString aName;
55 sal_uLong nValue;
56 bool bHasId;
57 public:
58 SvStringHashEntry()
59 : nValue(0)
60 , bHasId(false)
64 SvStringHashEntry( const OString& rName )
65 : aName(rName)
66 , nValue(0)
67 , bHasId(true)
71 const OString& GetName() const { return aName; }
72 bool HasId() const { return bHasId; }
74 void SetValue( sal_uLong n ) { nValue = n; }
75 sal_uLong GetValue() const { return nValue; }
78 class SvStringHashTable : public SvHashTable
80 SvStringHashEntry* pEntries;
81 protected:
82 virtual sal_uInt32 HashFunc( const OString& rElement ) const override;
83 virtual bool equals( const OString &rElement, sal_uInt32 nIndex ) const override;
84 public:
85 SvStringHashTable( sal_uInt32 nMaxEntries ); // max size of hash-tabel
86 virtual ~SvStringHashTable() override;
88 OString GetNearString( const OString& rName ) const;
89 virtual bool IsEntry( sal_uInt32 nIndex ) const override;
91 bool Insert( const OString& rStr, sal_uInt32 * pHash ); // insert string
92 bool Test( const OString& rStr, sal_uInt32 * pHash ) const; // test of insert string
93 SvStringHashEntry * Get ( sal_uInt32 nIndex ) const; // return pointer to string
96 #endif // INCLUDED_IDL_INC_HASH_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */