Map.h

Go to the documentation of this file.
00001 #ifndef JAVA_UTIL_MAP_H
00002 #define JAVA_UTIL_MAP_H 1
00003 
00004 #ifndef JAVA_UTIL_SET_H
00005 #include <java_util/Set.h>
00006 #endif /* JAVA_UTIL_SET_H */
00007 
00008 namespace java {
00009   namespace util {
00010 
00080     class JAVA_UTIL_SPEC Map : virtual public Interface {
00081 
00082     public:
00083 
00087       static Ref<Map> emptyMap();
00088 
00099       static Ref<Map> singletonMap(const ObjectRef& key, const ObjectRef& value);
00100 
00128       static Ref<Map> synchronizedMap(const Ref<Map>& map, const Ref<Sync>& sync = 0);
00129 
00141       static Ref<Map> immutableMap(const Ref<Map>& map);
00142 
00150       virtual jint size() const = 0;
00151 
00157       virtual jboolean isEmpty() const = 0;
00158 
00175       virtual jboolean containsKey(const ObjectRef& key) const = 0;
00176 
00193       virtual jboolean containsValue(const ObjectRef& value) const = 0;
00194 
00219       virtual ObjectRef get(const ObjectRef& key) const = 0;
00220 
00247       virtual ObjectRef put(const ObjectRef& key, const ObjectRef& value) = 0;
00248 
00274       virtual ObjectRef remove(const ObjectRef& key) = 0;
00275 
00298       virtual void putAll(const Map& t) = 0;
00299 
00306       virtual void clear() = 0;
00307 
00320       virtual Ref<Set> keySet() const = 0;
00321 
00335       virtual Ref<Collection> values() const = 0;
00336 
00350       virtual Ref<Set> entrySet() const = 0;
00351 
00352       /*
00353        * Compares the specified object with this map for equality.  Returns
00354        * <tt>true</tt> if the given object is also a map and the two Maps
00355        * represent the same mappings.  More formally, two maps <tt>t1</tt> and
00356        * <tt>t2</tt> represent the same mappings if
00357        * <tt>t1.entrySet().equals(t2.entrySet())</tt>.  This ensures that the
00358        * <tt>equals</tt> method works properly across different implementations
00359        * of the <tt>Map</tt> interface.
00360        *
00361        * @param o object to be compared for equality with this map.
00362        * @return <tt>true</tt> if the specified object is equal to this map.
00363        */
00364       //virtual jboolean equals(const Object& o) const = 0;
00365 
00366       /*
00367        * Returns the hash code value for this map.  The hash code of a map
00368        * is defined to be the sum of the hashCodes of each entry in the map's
00369        * entrySet view.  This ensures that <tt>t1.equals(t2)</tt> implies
00370        * that <tt>t1.hashCode()==t2.hashCode()</tt> for any two maps
00371        * <tt>t1</tt> and <tt>t2</tt>, as required by the general
00372        * contract of Object.hashCode.
00373        *
00374        * @return the hash code value for this map.
00375        */
00376       //virtual jint hashCode() const = 0;
00377 
00392       class JAVA_UTIL_SPEC Entry : virtual public Interface {
00393       public:
00394 
00400         virtual ObjectRef getKey() const = 0;
00401 
00409         virtual ObjectRef getValue() const = 0;
00410 
00430         virtual ObjectRef setValue(const ObjectRef& value) = 0;
00431 
00450         //virtual jboolean equals(const Object& o) const = 0;
00451 
00452         /*
00453          * Returns the hash code value for this map entry.  The hash code
00454          * of a map entry <tt>e</tt> is defined to be: <pre>
00455          *     (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
00456          *     (e.getValue()==null ? 0 : e.getValue().hashCode())
00457          * </pre>
00458          * This ensures that <tt>e1.equals(e2)</tt> implies that
00459          * <tt>e1.hashCode()==e2.hashCode()</tt> for any two Entries
00460          * <tt>e1</tt> and <tt>e2</tt>, as required by the general
00461          * contract of <tt>Object.hashCode</tt>.
00462          *
00463          * @return the hash code value for this map entry.
00464          * @see Object#hashCode()
00465          * @see Object#equals(Object)
00466          * @see #equals(Object)
00467          */
00468         //virtual jint hashCode() const = 0;
00469 
00470       private:
00471 
00472         REGISTER_MEMBERS;
00473 
00474       };
00475 
00476     private:
00477 
00478       REGISTER_MEMBERS;
00479 
00480     };
00481 
00482   } // namespace util
00483 } // namespace java
00484 
00485 #endif /* JAVA_UTIL_MAP_H */

Generated on Fri May 16 11:54:43 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3