]> git.saurik.com Git - wxWidgets.git/blame - include/wx/hashset.h
Cleaned up remains of outdated 3D effect handling.
[wxWidgets.git] / include / wx / hashset.h
CommitLineData
8142d704
MB
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/hashset.h
3// Purpose: wxHashSet class
4// Author: Mattia Barbon
5// Modified by:
6// Created: 11/08/2003
7// RCS-ID: $Id$
8// Copyright: (c) Mattia Barbon
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_HASHSET_H_
13#define _WX_HASHSET_H_
14
15#include "wx/hashmap.h"
16
17// this is a complex way of defining an easily inlineable identity function...
18#define _WX_DECLARE_HASH_SET_KEY_EX( KEY_T, CLASSNAME, CLASSEXP ) \
19CLASSEXP CLASSNAME \
20{ \
21 typedef KEY_T key_type; \
22 typedef const key_type const_key_type; \
23 typedef const_key_type& const_key_reference; \
24public: \
25 CLASSNAME() { } \
26 const_key_reference operator()( const_key_reference key ) const \
27 { return key; } \
28 \
29 /* the dummy assignment operator is needed to suppress compiler */ \
30 /* warnings from hash table class' operator=(): gcc complains about */ \
31 /* "statement with no effect" without it */ \
32 CLASSNAME& operator=(const CLASSNAME&) { return *this; } \
33};
34
35#define _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, CLASSEXP )\
36_WX_DECLARE_HASH_SET_KEY_EX( KEY_T, CLASSNAME##_wxImplementation_KeyEx, CLASSEXP ) \
37_WX_DECLARE_HASHTABLE( KEY_T, KEY_T, HASH_T, CLASSNAME##_wxImplementation_KeyEx, KEY_EQ_T, CLASSNAME##_wxImplementation_HashTable, CLASSEXP, grow_lf70, never_shrink ) \
38CLASSEXP CLASSNAME:public CLASSNAME##_wxImplementation_HashTable \
39{ \
40public: \
d8771ac7
MB
41 wxEXPLICIT CLASSNAME( size_type hint = 100, hasher hf = hasher(), \
42 key_equal eq = key_equal() ) \
8142d704
MB
43 : CLASSNAME##_wxImplementation_HashTable( hint, hf, eq, \
44 CLASSNAME##_wxImplementation_KeyEx() ) {} \
45 \
46 void insert( const key_type& key ) \
47 { \
48 GetOrCreateNode( key ); \
49 } \
50 \
51 const_iterator find( const const_key_type& key ) const \
52 { \
53 return const_iterator( GetNode( key ), this ); \
54 } \
55 \
56 iterator find( const const_key_type& key ) \
57 { \
58 return iterator( GetNode( key ), this ); \
59 } \
60 \
61 size_type erase( const key_type& k ) \
62 { return CLASSNAME##_wxImplementation_HashTable::erase( k ); } \
63 void erase( const iterator& it ) { erase( *it ); } \
64 void erase( const const_iterator& it ) { erase( *it ); } \
65 \
66 /* count() == 0 | 1 */ \
67 size_type count( const const_key_type& key ) \
68 { return GetNode( key ) ? 1 : 0; } \
69}
70
71// these macros are to be used in the user code
72#define WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME) \
73 _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, class )
74
75// and these do exactly the same thing but should be used inside the
76// library
77#define WX_DECLARE_HASH_SET_WITH_DECL( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, DECL) \
78 _WX_DECLARE_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME, DECL )
79
80#define WX_DECLARE_EXPORTED_HASH_SET( KEY_T, HASH_T, KEY_EQ_T, CLASSNAME) \
81 WX_DECLARE_HASH_SET_WITH_DECL( KEY_T, HASH_T, KEY_EQ_T, \
82 CLASSNAME, class WXDLLEXPORT )
83
84// delete all hash elements
85//
86// NB: the class declaration of the hash elements must be visible from the
87// place where you use this macro, otherwise the proper destructor may not
88// be called (a decent compiler should give a warning about it, but don't
89// count on it)!
90#define WX_CLEAR_HASH_SET(type, hashset) \
91 WX_CLEAR_HASH_MAP(type, hashset)
92
93#endif // _WX_HASHSET_H_