dict.hpp revision 1472
1472N/A * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// Dictionaries - An Abstract Data Type 0N/A// These dictionaries define a key-value mapping. They can be inserted to, 0N/A// searched or deleted from. They grow and shrink as needed. The key is a 0N/A// pointer to something (or anything which can be stored in a pointer). A 0N/A// key comparison routine determines if two keys are equal or not. A hash 0N/A// function can be provided; if it's not provided the key itself is used 0N/A// instead. A nice string hash function is included. 0N/A friend class DictI;
// Friendly iterator function 0N/A // cmp is a key comparision routine. hash is a routine to hash a key. 0N/A // Zap to empty; ready for re-use 0N/A // Return # of key-value pairs in dict 0N/A // Insert inserts the given key-value pair into the dictionary. The prior 0N/A // value of the key is returned; NULL if the key was not previously defined. 0N/A // Find finds the value of a given key; or NULL if not found. 0N/A // The dictionary is NOT changed. 0N/A void *
operator [](
const void *
key)
const;
// Do a lookup 0N/A // == compares two dictionaries; they must have the same keys (their keys 0N/A // must match using CmpKey) and they must have the same values (pointer 0N/A // comparison). If so 1 is returned, if not 0 is returned. 0N/A int32 operator ==(
const Dict &d)
const;
// Compare dictionaries for equal 0N/A // Print out the dictionary contents as key-value pairs 605N/A// Slimey cheap hash function; no guaranteed performance. Better than the 0N/A// default for pointers, especially on MS-DOS machines. 605N/A// Slimey cheap hash function; no guaranteed performance. 0N/A// Slimey cheap key comparator. 0N/A//------------------------------Iteration-------------------------------------- 0N/A// The class of dictionary iterators. Fails in the presences of modifications 0N/A// to the dictionary during iteration (including searches). 0N/A// Usage: for( DictI i(dict); i.test(); ++i ) { body = i.key; body = i.value;} 0N/A const Dict *
_d;
// Dictionary being iterated over 0N/A void operator ++(
void);
// Increment iterator