AGENT++  4.0.3
oidx_defs.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## AGENT++ 4.0 - oidx_defs.h
4  _##
5  _## Copyright (C) 2000-2013 Frank Fock and Jochen Katz (agentpp.com)
6  _##
7  _## Licensed under the Apache License, Version 2.0 (the "License");
8  _## you may not use this file except in compliance with the License.
9  _## You may obtain a copy of the License at
10  _##
11  _## http://www.apache.org/licenses/LICENSE-2.0
12  _##
13  _## Unless required by applicable law or agreed to in writing, software
14  _## distributed under the License is distributed on an "AS IS" BASIS,
15  _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  _## See the License for the specific language governing permissions and
17  _## limitations under the License.
18  _##
19  _##########################################################################*/
20 // This may look like C code, but it is really -*- C++ -*-
21 /*
22 Copyright (C) 1988 Free Software Foundation
23  written by Doug Lea (dl@rocky.oswego.edu)
24 
25 This file is part of the GNU C++ Library. This library is free
26 software; you can redistribute it and/or modify it under the terms of
27 the GNU Library General Public License as published by the Free
28 Software Foundation; either version 2 of the License, or (at your
29 option) any later version. This library is distributed in the hope
30 that it will be useful, but WITHOUT ANY WARRANTY; without even the
31 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
32 PURPOSE. See the GNU Library General Public License for more details.
33 You should have received a copy of the GNU Library General Public
34 License along with this library; if not, write to the Free Software
35 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 */
37 
38 
39 #ifndef _OidxPtrdefs_h
40 #define _OidxPtrdefs_h 1
41 
42 #include <agent_pp/oidx_ptr.h>
43 
44 #ifdef AGENTPP_NAMESPACE
45 namespace Agentpp {
46 #endif
47 
48 
49 // equality operator
50 #ifndef OidxPtrEQ
51 #define OidxPtrEQ(a, b) ((*a) == (*b))
52 #endif
53 
54 // less-than-or-equal
55 #ifndef OidxPtrLE
56 #define OidxPtrLE(a, b) ((*a) <= (*b))
57 #endif
58 
59 // comparison : less-than -> < 0; equal -> 0; greater-than -> > 0
60 #ifndef OidxPtrCMP
61 #define OidxPtrCMP(a, b) ( ((*a) <= (*b))? (((*a) == (*b))? 0 : -1) : 1 )
62 #endif
63 
64 // hash function
65 #ifndef OidxPtrHASH
66 extern unsigned int hash(OidxPtr );
67 #define OidxPtrHASH(x) hash(x)
68 #endif
69 
70 // initial capacity for structures requiring one
71 
72 #ifndef DEFAULT_INITIAL_CAPACITY
73 #define DEFAULT_INITIAL_CAPACITY 100
74 #endif
75 
76 // HASHTABLE_TOO_CROWDED(COUNT, SIZE) is true iff a hash table with COUNT
77 // elements and SIZE slots is too full, and should be resized.
78 // This is so if available space is less than 1/8.
79 
80 #define HASHTABLE_TOO_CROWDED(COUNT, SIZE) ((SIZE) - ((SIZE) >> 3) <= (COUNT))
81 
82 #ifdef AGENTPP_NAMESPACE
83 }
84 #endif
85 
86 #endif