~ubuntu-branches/debian/sid/coin2/sid

« back to all changes in this revision

Viewing changes to src/base/SbDict.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-06-28 02:38:17 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628023817-lgrh0u677j1gcqgf
Tags: 2.5.0-2
* debian/control: Change suggests from libopenal0 to libopenal0a.
  Closes: #488001.  Change ${Source-Version} to ${binary:Version}.
  Update to standards version 3.8.0.

* debian/rules: Do not ignore errors in clean rule.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************\
2
2
 *
3
3
 *  This file is part of the Coin 3D visualization library.
4
 
 *  Copyright (C) 1998-2006 by Systems in Motion.  All rights reserved.
 
4
 *  Copyright (C) 1998-2007 by Systems in Motion.  All rights reserved.
5
5
 *
6
6
 *  This library is free software; you can redistribute it and/or
7
7
 *  modify it under the terms of the GNU General Public License
98
98
  Callback for copying values from one SbDict to another.
99
99
*/
100
100
void
101
 
SbDict::copyval(unsigned long key, void * value, void * data)
 
101
SbDict::copyval(Key key, void * value, void * data)
102
102
{
103
103
  SbDict * thisp = (SbDict *)data;
104
104
  thisp->enter(key, value);
122
122
  data is changed to \a value, and \c FALSE is returned.
123
123
*/
124
124
SbBool
125
 
SbDict::enter(const unsigned long key, void * const value)
 
125
SbDict::enter(const Key key, void * const value)
126
126
{
127
127
  return cc_hash_put(this->hashtable, key, value);
128
128
}
133
133
  in \a value. Otherwise, \c FALSE is returned.
134
134
*/
135
135
SbBool
136
 
SbDict::find(const unsigned long key, void *& value) const
 
136
SbDict::find(const Key key, void *& value) const
137
137
{
138
138
  return cc_hash_get(this->hashtable, key, &value);
139
139
}
143
143
  with this key was present, \c FALSE otherwise.
144
144
*/
145
145
SbBool
146
 
SbDict::remove(const unsigned long key)
 
146
SbDict::remove(const Key key)
147
147
{
148
148
  return cc_hash_remove(this->hashtable, key);
149
149
}
154
154
// call that function from our dummy callback. This is needed since
155
155
// cc_hash only supports one apply function type.
156
156
extern "C" {
157
 
typedef void sbdict_dummy_apply_func(unsigned long, void *);
 
157
typedef void sbdict_dummy_apply_func(SbDict::Key, void *);
158
158
 
159
159
static void
160
 
sbdict_dummy_apply(unsigned long key, void * value, void * closure)
 
160
sbdict_dummy_apply(SbDict::Key key, void * value, void * closure)
161
161
{
162
162
  sbdict_dummy_apply_func * func = (sbdict_dummy_apply_func*) closure;
163
163
  func(key, value);
167
167
  Applies \a rtn to all entries in the dictionary.
168
168
*/
169
169
void
170
 
SbDict::applyToAll(void (* rtn)(unsigned long key, void * value)) const
 
170
SbDict::applyToAll(void (* rtn)(Key key, void * value)) const
171
171
{
172
172
  cc_hash_apply(this->hashtable, sbdict_dummy_apply, (void*) rtn);
173
173
}
176
176
  \overload
177
177
*/
178
178
void
179
 
SbDict::applyToAll(void (* rtn)(unsigned long key, void * value, void * data),
 
179
SbDict::applyToAll(void (* rtn)(Key key, void * value, void * data),
180
180
                   void * data) const
181
181
{
182
182
  cc_hash_apply(this->hashtable, (cc_hash_apply_func*)rtn, data);
189
189
 
190
190
 
191
191
static void
192
 
sbdict_makeplist_cb(unsigned long key, void * value, void * closure)
 
192
sbdict_makeplist_cb(SbDict::Key key, void * value, void * closure)
193
193
{
194
194
  sbdict_makeplist_data * data = (sbdict_makeplist_data*) closure;
195
195
  // Extra cast through uintptr_t to avoid a warning with MSVC 7 on
220
220
  clusters in only a few buckets, you should try setting a hashing
221
221
  function. If you're for instance using strings, you could use the
222
222
  static SbString::hash() function (you'd need to make a static function
223
 
  that will cast from unsigned long to char * of course).
 
223
  that will cast from SbDict::Key to char * of course).
224
224
 
225
225
  This function is not part of the OIV API.
226
226
*/
227
227
void
228
 
SbDict::setHashingFunction(unsigned long (*func)(const unsigned long key))
 
228
SbDict::setHashingFunction(Key (*func)(const Key key))
229
229
{
230
230
  cc_hash_set_hash_func(this->hashtable, (cc_hash_func *)func);
231
231
}