KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bak > pcj > map > LongKeyMap


1 /*
2  * Primitive Collections for Java.
3  * Copyright (C) 2002, 2003 Søren Bak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package bak.pcj.map;
20
21 import bak.pcj.set.LongSet;
22
23 /**
24  * This interface represents maps from long values to objects.
25  *
26  * @see java.util.Map
27  *
28  * @author Søren Bak
29  * @version 1.1 2003/6/1
30  * @since 1.0
31  */

32 public interface LongKeyMap {
33
34     /**
35      * Clears this map.
36      */

37     void clear();
38
39     /**
40      * Indicates whether this map contains a mapping from a specified
41      * key.
42      *
43      * @param key
44      * the key to test for.
45      *
46      * @return <tt>true</tt> if this map contains a mapping from
47      * the specified key; returns <tt>false</tt>
48      * otherwise.
49      */

50     boolean containsKey(long key);
51
52     /**
53      * Indicates whether this map contains a mapping to a specified
54      * value.
55      *
56      * @param value
57      * the value to test for.
58      *
59      * @return <tt>true</tt> if this map contains at least one
60      * mapping to the specified value; returns
61      * <tt>false</tt> otherwise.
62      */

63     boolean containsValue(Object JavaDoc value);
64
65     /**
66      * Returns an iterator over the entries of this map. It is
67      * possible to remove entries from this map using the iterator
68      * provided that the concrete map supports removal of
69      * entries.
70      *
71      * @return an iterator over the entries of this map.
72      */

73     LongKeyMapIterator entries();
74
75     /**
76      * Indicates whether this map is equal to some object.
77      *
78      * @param obj
79      * the object with which to compare this map.
80      *
81      * @return <tt>true</tt> if this map is equal to the
82      * specified object; returns <tt>false</tt>
83      * otherwise.
84      */

85     boolean equals(Object JavaDoc obj);
86
87     /**
88      * Maps a specified key to a value.
89      *
90      * @param key
91      * the key to map to a value.
92      *
93      * @return the value that the specified key maps to; returns
94      * <tt>null</tt>, if no mapping exists for the
95      * specified key.
96      */

97     Object JavaDoc get(long key);
98
99     /**
100      * Returns a hash code value for this map.
101      *
102      * @return a hash code value for this map.
103      */

104     int hashCode();
105
106     /**
107      * Indicates whether this map is empty.
108      *
109      * @return <tt>true</tt> if this map is empty; returns
110      * <tt>false</tt> otherwise.
111      */

112     public boolean isEmpty();
113
114     /**
115      * Returns a set view of the keys of this map. The set is not
116      * directly modifiable, but changes to the map are reflected in
117      * the set.
118      *
119      * @return a set view of the keys of this map.
120      */

121     LongSet keySet();
122
123     /**
124      * Adds a mapping from a specified key to a specified value to
125      * this map. If a mapping already exists for the specified key
126      * it is overwritten by the new mapping.
127      *
128      * @param key
129      * the key of the mapping to add to this map.
130      *
131      * @param value
132      * the value of the mapping to add to this map.
133      *
134      * @return the old value (which can be <tt>null</tt>) if a
135      * mapping from the specified key already existed
136      * in this map; returns <tt>null</tt> otherwise.
137      *
138      * @throws UnsupportedOperationException
139      * if the operation is not supported by this map.
140      */

141     Object JavaDoc put(long key, Object JavaDoc value);
142
143     /**
144      * Adds all mappings from a specified map to this map. Any
145      * existing mappings whose keys collide with a new mapping is
146      * overwritten by the new mapping.
147      *
148      * @param map
149      * the map whose mappings to add to this map.
150      *
151      * @throws NullPointerException
152      * if <tt>map</tt> is <tt>null</tt>.
153      *
154      * @throws UnsupportedOperationException
155      * if the operation is not supported by this map.
156      */

157     void putAll(LongKeyMap map);
158
159     /**
160      * Removes the mapping from a specified key from this map.
161      *
162      * @param key
163      * the key whose mapping to remove from this map.
164      *
165      * @return the old value (which can be <tt>null</tt>) if a
166      * mapping from the specified key already existed
167      * in this map; returns <tt>null</tt> otherwise.
168      *
169      * @throws UnsupportedOperationException
170      * if the operation is not supported by this map.
171      */

172     Object JavaDoc remove(long key);
173
174     /**
175      * Returns the size of this map. The size is defined as the
176      * number of mappings from keys to values.
177      *
178      * @return the size of this map.
179      */

180     int size();
181
182     /**
183      * Returns a collection view of the values in this map. The
184      * collection is not modifiable, but changes to the map are
185      * reflected in the collection.
186      *
187      * @return a collection view of the values in this map.
188      */

189     java.util.Collection JavaDoc values();
190
191 }
Popular Tags