//----------------------------------------------------------------------- /** * Replaces the superclass method to store the state of this class. * <p> * Serialization is not one of the JDK's nicest topics. Normal serialization will * initialise the superclass before the subclass. Sometimes however, this isn't * what you want, as in this case the <code>put()</code> method on read can be * affected by subclass state. * <p> * The solution adopted here is to serialize the state data of this class in * this protected method. This method must be called by the * <code>writeObject()</code> of the first java.io.Serializable subclass. * <p> * Subclasses may override if they have a specific field that must be present * on read before this implementation will work. Generally, the read determines * what must be serialized here, if anything. * * @param out the output stream */ protected void dowriteObject(java.io.ObjectOutputStream outJ) {//throws IOException { outJ.writeInt(keyType); outJ.writeInt(valueType); outJ.writeBoolean(purgeValues); outJ.writeFloat(loadFactor); outJ.writeInt(data.Length); for (MapIterator it = mapIterator(); it.hasNext();) { outJ.writeObject(it.next()); outJ.writeObject(it.getValue()); } outJ.writeObject(null); // null terminate map // do not call base.doWriteObject() as code there doesn't work for reference map }
//----------------------------------------------------------------------- /** * Removes all mappings where the first key is that specified. * <p> * This method removes all the mappings where the <code>MultiKey</code> * has one or more keys, and the first matches that specified. * * @param key1 the first key * @return true if any elements were removed */ public bool removeAll(Object key1) { bool modified = false; MapIterator it = mapIterator(); while (it.hasNext()) { MultiKey multi = (MultiKey)it.next(); if (multi.size() >= 1 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0)))) { it.remove(); modified = true; } } return(modified); }
/** * Removes all mappings where the first four keys are those specified. * <p> * This method removes all the mappings where the <code>MultiKey</code> * has four or more keys, and the first four match those specified. * * @param key1 the first key * @param key2 the second key * @param key3 the third key * @param key4 the fourth key * @return true if any elements were removed */ public bool removeAll(Object key1, Object key2, Object key3, Object key4) { bool modified = false; MapIterator it = mapIterator(); while (it.hasNext()) { MultiKey multi = (MultiKey)it.next(); if (multi.size() >= 4 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) && (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) && (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)))) { it.remove(); modified = true; } } return(modified); }
//----------------------------------------------------------------------- public bool hasNext() { return(iterator.hasNext()); }