VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oldHashList.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1997 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: oldHashList.h,v $ $Revision: 1.2 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef oldHashList_H_
10 #define oldHashList_H_
11 
12 #include "vlList.h"
13 
14 // This file is no longer part of VR-Link. The header and source are provided
15 // as an example for customers who require backwards compatability. These
16 // classes are no longer supported by MAK. Customers may use the classes
17 // as they wish without obtaining permission from MAK.
18 
19 // In VR-Link 3.3, we significantly changed the semantics of our DtHashlist
20 // class. The new version is defined in hashlist.h. The older DtHashlist
21 // class has been renamed DtOldHashlist, and is still defined here in this
22 // file for backwards compatibility. While we suggest that you port your
23 // code to the new DtHashlist, which is cleaner and easier to use, if you
24 // do not want to make that change, you can just use DtOldHashlist wherever
25 // you used to use DtHashlist, and the rest of your old code should work.
26 
27 #ifdef DtUSE_UTILITIES_NAMESPACE
28 namespace DtUSE_UTILITIES_NAMESPACE
29 {
30 #endif
31 
33 {
34  DtHashKey(int ii) { i = ii; }
35  DtHashKey(const void *pp) { p = (void *) pp; }
36  int i;
37  void *p;
38 };
39 
41 {
42  public:
43  friend class DtOldHashlist;
44 
45  DtHashKey key() { return myKey; }
46  DtListItem *listItem() { return myItem; }
47  protected:
48  DtHashedItem(DtHashKey k, DtListItem *item) : myKey(k), myItem(item) {}
51 };
52 
54 {
55  public:
56  DtOldHashlist(unsigned numBuckets);
57  virtual ~DtOldHashlist();
58 
59  const DtList *list() const;
60  virtual unsigned hash(DtHashKey key) const;
61  virtual int isEqual(DtHashKey key1, DtHashKey key2) const;
62 
63  // In the event that an Item with key already exists, then add
64  // will replace the data and move it to the location in list.
65  // If your data was alloced, do not add unless you know key is
66  // unique, or a memory leak will result.
67 
68  DtListItem *add (DtHashKey key, void *data);
69  DtListItem *addToStart(DtHashKey key, void *data);
70  DtListItem *addToEnd (DtHashKey key, void *data);
71  DtListItem *addBefore(DtHashKey key, void *data,
72  DtListItem *before);
73  DtListItem *addAfter(DtHashKey key, void *data,
74  DtListItem *after);
75 
76  virtual void *remove(DtHashKey key);
77  virtual void *operator[] (DtHashKey key) const;
78  virtual void *lookup(DtHashKey key) const;
79 
80  DtListItem *itemLookup(DtHashKey key) const;
81 
82  unsigned nBuckets(void) const;
83  unsigned bucketCount(unsigned index) const;
84 
85  protected:
86  DtList *bucket(DtHashKey key) const;
87  void addToBucket(DtHashKey k, DtListItem *item);
88  DtListItem *removeFromBucket(DtHashKey key);
91  unsigned nbuck;
92 };
93 
94 inline const DtList *DtOldHashlist::list() const
95 {
96  return myList;
97 }
98 
99 inline int DtOldHashlist::isEqual(DtHashKey key1, DtHashKey key2) const
100 {
101  return key1.i == key2.i;
102 }
103 
104 inline unsigned DtOldHashlist::hash(DtHashKey key) const
105 {
106  return key.i % nbuck;
107 }
108 
110 {
111  return &buckets[hash(key)];
112 }
113 
114 inline void *DtOldHashlist::lookup (DtHashKey key) const
115 {
116  DtListItem *item = itemLookup(key);
117  return (item ? item->data() : NULL);
118 }
119 
120 inline void *DtOldHashlist::operator[] (DtHashKey key) const
121 {
122  return lookup(key);
123 }
124 
125 inline unsigned int DtOldHashlist::nBuckets() const
126 {
127  return nbuck;
128 }
129 
130 inline unsigned int DtOldHashlist::bucketCount(unsigned index) const
131 {
132  return buckets[index].count();
133 }
134 
135 inline DtListItem *DtOldHashlist::add(DtHashKey key, void *data)
136 {
137  return addAfter(key, data, list()->last());
138 }
139 
141 {
142  return addAfter(key, data, NULL);
143 }
144 
145 inline DtListItem *DtOldHashlist::addToEnd (DtHashKey key, void *data)
146 {
147  return addAfter(key, data, list()->last());
148 }
149 
151  DtListItem *before)
152 {
153  return addAfter(key, data, before ? before->prev() : (DtListItem*)NULL);
154 }
155 
157 {
158  public:
159  DtOldIntrusiveHashlist(unsigned numBuckets);
160 };
161 
162 #ifdef DtUSE_UTILITIES_NAMESPACE
163 } // end of namespace DtUSE_UTILITIES_NAMESPACE
164 #endif
165 
166 #endif /* _HASHLIST_H_ */
Definition: oldHashList.h:40
DtHashKey(int ii)
Definition: oldHashList.h:34
This file contains the declaration of DtList and DtListItem.
virtual void * operator[](DtHashKey key) const
Definition: oldHashList.h:120
virtual void * lookup(DtHashKey key) const
Definition: oldHashList.h:114
DtListItem * prev() const
Return previous (next) item.
Definition: vlList.h:221
unsigned bucketCount(unsigned index) const
Definition: oldHashList.h:130
DtHashKey key()
Definition: oldHashList.h:45
Definition: oldHashList.h:156
DtListItem * listItem()
Definition: oldHashList.h:46
DtListItem * myItem
Definition: oldHashList.h:50
DtHashKey myKey
Definition: oldHashList.h:49
unsigned nBuckets(void) const
Definition: oldHashList.h:125
Definition: oldHashList.h:53
DtList is deprecated, please use std::list<T>.
Definition: vlList.h:71
virtual unsigned hash(DtHashKey key) const
Definition: oldHashList.h:104
DtList * myList
Definition: oldHashList.h:89
DtListItem * addBefore(DtHashKey key, void *data, DtListItem *before)
Definition: oldHashList.h:150
DtHashedItem(DtHashKey k, DtListItem *item)
Definition: oldHashList.h:48
void * p
Definition: oldHashList.h:37
DtHashKey(const void *pp)
Definition: oldHashList.h:35
lint -e266
Definition: vlList.h:25
int i
Definition: oldHashList.h:36
unsigned nbuck
Definition: oldHashList.h:91
void * data() const
Returns the data element contained in the DtListItem envelope.
Definition: vlList.h:231
virtual int isEqual(DtHashKey key1, DtHashKey key2) const
Definition: oldHashList.h:99
DtListItem * add(DtHashKey key, void *data)
Definition: oldHashList.h:135
DtList * bucket(DtHashKey key) const
Definition: oldHashList.h:109
DtListItem * addToEnd(DtHashKey key, void *data)
Definition: oldHashList.h:145
const DtList * list() const
Definition: oldHashList.h:94
DtListItem * addToStart(DtHashKey key, void *data)
Definition: oldHashList.h:140
DtList * buckets
Definition: oldHashList.h:90
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109
Definition: oldHashList.h:32

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)