/usr/include/dcmtk/dcmdata/dchashdi.h is in libdcmtk-dev 3.6.2-3build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | /*
*
* Copyright (C) 1994-2017, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmdata
*
* Author: Andrew Hewett
*
* Purpose: Hash table interface for DICOM data dictionary
*
*/
#ifndef DCHASHDI_H
#define DCHASHDI_H
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/ofstd/oflist.h"
#include "dcmtk/ofstd/ofstream.h"
#include "dcmtk/dcmdata/dcdefine.h"
class DcmDictEntry;
class DcmTagKey;
class DcmHashDict;
typedef OFListIterator(DcmDictEntry *) DcmDictEntryListIterator;
typedef OFListConstIterator(DcmDictEntry *) DcmDictEntryListConstIterator;
/** an ordered list of pointers to DcmDictEntry objects
*/
class DCMTK_DCMDATA_EXPORT DcmDictEntryList
{
public:
/// constructor
DcmDictEntryList() : list_() {}
/// destructor
~DcmDictEntryList();
/// clears list and deletes all entries
void clear();
/// @return the number of elements in this list
unsigned int size() const;
/// @return True if this list is empty
OFBool empty() const;
/// @return Iterator to the beginning of the list
DcmDictEntryListIterator begin();
/// @return Iterator past the end of the list
DcmDictEntryListIterator end();
/// @return Iterator to the beginning of the list
DcmDictEntryListConstIterator begin() const;
/// @return Iterator past the end of the list
DcmDictEntryListConstIterator end() const;
/** Insert a new element in the list
* @param position Position to insert after
* @param entry Entry to insert
* @return Iterator to the new entry
*/
DcmDictEntryListIterator insert(DcmDictEntryListIterator position, DcmDictEntry *entry);
/** Remove an element from the list.
* @param entry The entry to remove
*/
void remove(DcmDictEntry *entry);
/** Append a new entry to the list.
* @param entry The entry to append.
*/
void push_back(DcmDictEntry *entry);
/** inserts an entry into the list and returns any replaced entry
* @param entry new list entry
* @return replaced list entry or NULL
*/
DcmDictEntry* insertAndReplace(DcmDictEntry* entry);
/** find an entry in the set
* @param key tag key of the entry to be searched for
* @param privCreator private creator name, may be NULL
* @return pointer to entry (if found), otherwise NULL
*/
DcmDictEntry *find(const DcmTagKey& key, const char *privCreator);
private:
/// private undefined copy constructor
DcmDictEntryList(const DcmDictEntryList&);
/// private undefined copy assignment operator
DcmDictEntryList& operator=(const DcmDictEntryList&);
/// list of entries
OFList<DcmDictEntry *> list_;
};
/** iterator class for traversing a DcmHashDict
*/
class DCMTK_DCMDATA_EXPORT DcmHashDictIterator
{
public:
/// default constructor
DcmHashDictIterator()
: dict(NULL), hindex(0), iterating(OFFalse), iter()
{ init(NULL); }
/** constructor, creates iterator to existing hash dictionary
* @param d pointer to dictionary
* @param atEnd if true, iterator points after last element
* of hash dictionary, otherwise iterator points to first element
*/
DcmHashDictIterator(const DcmHashDict* d, OFBool atEnd = OFFalse)
: dict(NULL), hindex(0), iterating(OFFalse), iter()
{ init(d, atEnd); }
/// copy constructor
DcmHashDictIterator(const DcmHashDictIterator& i)
: dict(i.dict), hindex(i.hindex), iterating(i.iterating), iter(i.iter)
{ }
/// copy assignment operator
DcmHashDictIterator& operator=(const DcmHashDictIterator& i)
{ dict = i.dict; hindex = i.hindex;
iterating = i.iterating; iter = i.iter; return *this; }
/// comparison equality
OFBool operator==(const DcmHashDictIterator& x) const
{ return iterating ? x.iterating && (hindex == x.hindex) && (iter == x.iter) : !x.iterating; }
/// comparison non-equality
OFBool operator!=(const DcmHashDictIterator& x) const
{ return !(*this == x); }
/// dereferencing of iterator
const DcmDictEntry* operator*() const
{ return (*iter); }
/// pre-increment operator
DcmHashDictIterator& operator++()
{ stepUp(); return *this; }
/// post-increment operator
DcmHashDictIterator operator++(int)
{ DcmHashDictIterator tmp(*this); stepUp(); return tmp; }
private:
/** initializes the iterator
* @param d pointer to hash dictionary, may be NULL
* @param atEnd if true, iterator points after last element
* of hash dictionary, otherwise iterator points to first element
*/
void init(const DcmHashDict *d, OFBool atEnd = OFFalse);
/** implements increment operator on hash dictionary
*/
void stepUp();
/// pointer to the hash dictionary this iterator traverses
const DcmHashDict* dict;
/// index of current bucket
int hindex;
/// flag indicating if iter is currently valid
OFBool iterating;
/// iterator for traversing a bucket in the hash table
DcmDictEntryListIterator iter;
};
/** a hash table of pointers to DcmDictEntry objects
*/
class DCMTK_DCMDATA_EXPORT DcmHashDict
{
public:
/// default constructor
DcmHashDict()
: hashTab(NULL), lowestBucket(0), highestBucket(0), entryCount(0)
{ _init(); }
/// destructor
~DcmHashDict();
/** counts total number of entries
* @return number of entries
*/
int size() const { return entryCount; }
/// clears the hash table of all entries
void clear();
/** inserts an entry into hash table (deletes old entry if present)
* @param entry pointer to new entry
*/
void put(DcmDictEntry* entry);
/** hash table lookup for the given tag key and private creator name
* @param key tag key of the entry to be searched for
* @param privCreator private creator name, may be NULL
* @return pointer to entry (if found), otherwise NULL
*/
const DcmDictEntry* get(const DcmTagKey& key, const char *privCreator) const;
/** deletes the entry for the given tag and private creator
* @param key tag key of the entry to be deleted
* @param privCreator private creator name, may be NULL
*/
void del(const DcmTagKey& key, const char *privCreator);
// iterator over the contents of the hash table
friend class DcmHashDictIterator;
/// returns iterator to start of hash table
DcmHashDictIterator begin() const
{ DcmHashDictIterator iter(this); return iter; }
/// returns iterator to end of hash table
DcmHashDictIterator end() const
{ DcmHashDictIterator iter(this, OFTrue); return iter; }
/// prints some information about hash table bucket utilization
STD_NAMESPACE ostream& loadSummary(STD_NAMESPACE ostream& out);
private:
/// private unimplemented copy constructor
DcmHashDict(const DcmHashDict &);
/// private unimplemented copy assignment operator
DcmHashDict &operator=(const DcmHashDict &);
/// performs initialization for given hash table size, called from constructor
void _init();
/** compute hash value for given tag key
* @param key pointer to tag key
* @param privCreator private creator name, may be NULL
* @return hash value
*/
int hash(const DcmTagKey* key, const char *privCreator) const;
/** inserts new entry into given list
* @param lst list to add to
* @param entry new element to add, will be deleted upon destruction of the hash table
* @return pointer to replaced element, if any
*/
DcmDictEntry* insertInList(DcmDictEntryList& lst, DcmDictEntry* entry);
/** removes the entry for the given tag and private creator
* @param lst list to remove from
* @param key tag key of the entry to be removed
* @param privCreator private creator name, may be NULL
* @return pointer to removed element, if any
*/
DcmDictEntry* removeInList(DcmDictEntryList& lst, const DcmTagKey& key, const char *privCreator);
/** searches entry for the given tag and private creator
* @param lst list to search in
* @param key tag key of the entry to be searched for
* @param privCreator private creator name, may be NULL
* @return pointer to found element, NULL if not found
*/
DcmDictEntry* findInList(DcmDictEntryList& lst, const DcmTagKey& key, const char *privCreator) const;
/** array of (hash table size) pointers to DcmDictEntryList elements
* implementing the different buckets of the hash table
*/
DcmDictEntryList** hashTab;
/// number of buckets in hash table
static const int hashTabLength;
/// index of lowest bucket for which the DcmDictEntryList has been initialized
int lowestBucket;
/// index of highest bucket for which the DcmDictEntryList has been initialized
int highestBucket;
/// number of entries in hash table
int entryCount;
};
#endif /* DCHASHDI_H */
|