2 #ifndef JAWS_ASSOC_ARRAY_H
3 #define JAWS_ASSOC_ARRAY_H
5 template <class KEY
, class DATA
> class JAWS_Assoc_Array_Iterator
;
7 template <class KEY
, class DATA
>
11 friend class JAWS_Assoc_Array_Iterator
<KEY
, DATA
>;
14 JAWS_Assoc_Array (int maxsize
= 1024);
15 ~JAWS_Assoc_Array (void);
17 int index (const KEY
&k
);
18 // Returns the index into the array associated with key k
19 // Returns -1 if not found.
21 DATA
* find (const KEY
&k
);
22 // Returns the data associated with key k. 0 if not found.
24 DATA
* find_by_index (int i
);
25 // Returns the data associated with array index i. Returns 0 if the
28 DATA
* insert (const KEY
&k
, const DATA
&d
);
29 // Inserts a *copy* of the key and data into the associated array.
30 // Both KEY and DATA must have well defined semantics for copy
31 // construction. This method returns a pointer to the inserted item
32 // copy, or 0 if an error occurred. NOTE: if an identical key
33 // already exists in the tree, no new item is created, and the
34 // returned pointer addresses the existing item associated with the
37 int remove (const KEY
&k
);
38 // Removes the item associated with the given key from the
39 // tree and destroys it. Returns 1 if it found the item
40 // and successfully destroyed it, 0 if it did not find the
41 // item, or -1 if an error occurred.
44 // Destroys all keys and associated data.
48 int find_i (const KEY
&k
);
49 // If k points to an associated data item, then this function
50 // returns the index into the arrays that hold it. Otherwise, it
51 // returns an index suitable to insert the item. If the item is not
52 // found and the table is full, maxsize_ is returned.
60 template <class KEY
, class DATA
>
61 class JAWS_Assoc_Array_Iterator
65 JAWS_Assoc_Array_Iterator (const JAWS_Assoc_Array
<KEY
, DATA
> &aa
);
66 ~JAWS_Assoc_Array_Iterator (void);
79 // declare private and do not define: explicitly
80 // prevent assignment and copy construction of iterators
81 JAWS_Assoc_Array_Iterator (const JAWS_Assoc_Array_Iterator
<KEY
, DATA
> &);
82 void operator= (const JAWS_Assoc_Array_Iterator
<KEY
, DATA
> &);
86 const JAWS_Assoc_Array
<KEY
, DATA
> &aa_
;
89 // The current item pointed by iterator.
92 // The next item to be pointed to by iterator.
96 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
97 #include "JAWS/Assoc_Array.cpp"
98 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
100 #endif /* !defined (JAWS_ASSOC_ARRAY_H) */