org.apache.commons.collections.MapIterator Java Examples
The following examples show how to use
org.apache.commons.collections.MapIterator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiKeyMap.java From Penetration_Testing_POC with Apache License 2.0 | 6 votes |
/** * Removes all mappings where the first three keys are those specified. * <p> * This method removes all the mappings where the <code>MultiKey</code> * has three or more keys, and the first three match those specified. * * @param key1 the first key * @param key2 the second key * @param key3 the third key * @return true if any elements were removed */ public boolean removeAll(Object key1, Object key2, Object key3) { boolean modified = false; MapIterator it = mapIterator(); while (it.hasNext()) { MultiKey multi = (MultiKey) it.next(); if (multi.size() >= 3 && (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)))) { it.remove(); modified = true; } } return modified; }
Example #2
Source File: MultiKeyMap.java From Penetration_Testing_POC with Apache License 2.0 | 6 votes |
/** * 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 boolean removeAll(Object key1, Object key2, Object key3, Object key4) { boolean 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; }
Example #3
Source File: AbstractHashedMap.java From Penetration_Testing_POC with Apache License 2.0 | 6 votes |
/** * Gets the map as a String. * * @return a string version of the map */ public String toString() { if (size() == 0) { return "{}"; } StringBuffer buf = new StringBuffer(32 * size()); buf.append('{'); MapIterator it = mapIterator(); boolean hasNext = it.hasNext(); while (hasNext) { Object key = it.next(); Object value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=') .append(value == this ? "(this Map)" : value); hasNext = it.hasNext(); if (hasNext) { buf.append(',').append(' '); } } buf.append('}'); return buf.toString(); }
Example #4
Source File: ContainerCache.java From hadoop-ozone with Apache License 2.0 | 6 votes |
/** * Closes all the db instances and resets the cache. */ public void shutdownCache() { lock.lock(); try { // iterate the cache and close each db MapIterator iterator = cache.mapIterator(); while (iterator.hasNext()) { iterator.next(); ReferenceCountedDB db = (ReferenceCountedDB) iterator.getValue(); Preconditions.checkArgument(db.cleanup(), "refCount:", db.getReferenceCount()); } // reset the cache cache.clear(); } finally { lock.unlock(); } }
Example #5
Source File: TreeBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 6 votes |
/** * Gets the string form of this map as per AbstractMap. * * @param index the KEY or VALUE int * @return the string form of this map */ private String doToString(final int type) { if (nodeCount == 0) { return "{}"; } StringBuffer buf = new StringBuffer(nodeCount * 32); buf.append('{'); MapIterator it = new ViewMapIterator(this, type); boolean hasNext = it.hasNext(); while (hasNext) { Object key = it.next(); Object value = it.getValue(); buf.append(key == this ? "(this Map)" : key) .append('=') .append(value == this ? "(this Map)" : value); hasNext = it.hasNext(); if (hasNext) { buf.append(", "); } } buf.append('}'); return buf.toString(); }
Example #6
Source File: UnmodifiableMapIterator.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Decorates the specified iterator such that it cannot be modified. * * @param iterator the iterator to decorate * @throws IllegalArgumentException if the iterator is null */ public static MapIterator decorate(MapIterator iterator) { if (iterator == null) { throw new IllegalArgumentException("MapIterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableMapIterator(iterator); }
Example #7
Source File: MultiKeyMap.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * 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 boolean removeAll(Object key1) { boolean 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; }
Example #8
Source File: MultiKeyMap.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Removes all mappings where the first two keys are those specified. * <p> * This method removes all the mappings where the <code>MultiKey</code> * has two or more keys, and the first two match those specified. * * @param key1 the first key * @param key2 the second key * @return true if any elements were removed */ public boolean removeAll(Object key1, Object key2) { boolean modified = false; MapIterator it = mapIterator(); while (it.hasNext()) { MultiKey multi = (MultiKey) it.next(); if (multi.size() >= 2 && (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) && (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)))) { it.remove(); modified = true; } } return modified; }
Example #9
Source File: AbstractMapIteratorDecorator.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Constructor that decorates the specified iterator. * * @param iterator the iterator to decorate, must not be null * @throws IllegalArgumentException if the collection is null */ public AbstractMapIteratorDecorator(MapIterator iterator) { super(); if (iterator == null) { throw new IllegalArgumentException("MapIterator must not be null"); } this.iterator = iterator; }
Example #10
Source File: Flat3Map.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Write the map out using a custom routine. */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeInt(size()); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); // key out.writeObject(it.getValue()); // value } }
Example #11
Source File: TreeBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 5 votes |
/** * Gets the hash code value for this map as per the API. * * @param index the KEY or VALUE int * @return the hash code value for this map */ private int doHashCode(final int type) { int total = 0; if (nodeCount > 0) { for (MapIterator it = new ViewMapIterator(this, type); it.hasNext(); ) { Object key = it.next(); Object value = it.getValue(); total += (key.hashCode() ^ value.hashCode()); } } return total; }
Example #12
Source File: TreeBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { if (isEmpty()) { return EmptyOrderedMapIterator.INSTANCE; } return new ViewMapIterator(main, VALUE); }
Example #13
Source File: UnmodifiableOrderedBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return orderedMapIterator(); }
Example #14
Source File: UnmodifiableBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { MapIterator it = getBidiMap().mapIterator(); return UnmodifiableMapIterator.decorate(it); }
Example #15
Source File: UnmodifiableOrderedMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { MapIterator it = getOrderedMap().mapIterator(); return UnmodifiableMapIterator.decorate(it); }
Example #16
Source File: UnmodifiableSortedBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return orderedMapIterator(); }
Example #17
Source File: MultiKeyMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return map.mapIterator(); }
Example #18
Source File: ListOrderedMap.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return orderedMapIterator(); }
Example #19
Source File: AbstractOrderedMapDecorator.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return getOrderedMap().mapIterator(); }
Example #20
Source File: AbstractBidiMapDecorator.java From Penetration_Testing_POC with Apache License 2.0 | 4 votes |
public MapIterator mapIterator() { return getBidiMap().mapIterator(); }
Example #21
Source File: AbstractHashedMap.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * Gets an iterator over the map. * Changes made to the iterator affect this map. * <p> * A MapIterator returns the keys in the map. It also provides convenient * methods to get the key and value, and set the value. * It avoids the need to create an entrySet/keySet/values object. * It also avoids creating the Map.Entry object. * * @return the map iterator */ public MapIterator mapIterator() { if (size == 0) { return EmptyMapIterator.INSTANCE; } return new HashMapIterator(this); }
Example #22
Source File: TreeBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * Gets an iterator over the map entries. * <p> * For this map, this iterator is the fastest way to iterate over the entries. * * @return an iterator */ public MapIterator mapIterator() { if (isEmpty()) { return EmptyOrderedMapIterator.INSTANCE; } return new ViewMapIterator(this, KEY); }
Example #23
Source File: AbstractHashedMap.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * Writes the map data to the stream. This method must be overridden if a * subclass must be setup before <code>put()</code> is used. * <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 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(ObjectOutputStream out) throws IOException { out.writeFloat(loadFactor); out.writeInt(data.length); out.writeInt(size); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue()); } }
Example #24
Source File: AbstractReferenceMap.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * 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 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(ObjectOutputStream out) throws IOException { out.writeInt(keyType); out.writeInt(valueType); out.writeBoolean(purgeValues); out.writeFloat(loadFactor); out.writeInt(data.length); for (MapIterator it = mapIterator(); it.hasNext();) { out.writeObject(it.next()); out.writeObject(it.getValue()); } out.writeObject(null); // null terminate map // do not call super.doWriteObject() as code there doesn't work for reference map }
Example #25
Source File: AbstractLinkedMap.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * Gets an iterator over the map. * Changes made to the iterator affect this map. * <p> * A MapIterator returns the keys in the map. It also provides convenient * methods to get the key and value, and set the value. * It avoids the need to create an entrySet/keySet/values object. * * @return the map iterator */ public MapIterator mapIterator() { if (size == 0) { return EmptyOrderedMapIterator.INSTANCE; } return new LinkMapIterator(this); }
Example #26
Source File: Flat3Map.java From Penetration_Testing_POC with Apache License 2.0 | 3 votes |
/** * Gets an iterator over the map. * Changes made to the iterator affect this map. * <p> * A MapIterator returns the keys in the map. It also provides convenient * methods to get the key and value, and set the value. * It avoids the need to create an entrySet/keySet/values object. * It also avoids creating the Map Entry object. * * @return the map iterator */ public MapIterator mapIterator() { if (delegateMap != null) { return delegateMap.mapIterator(); } if (size == 0) { return EmptyMapIterator.INSTANCE; } return new FlatMapIterator(this); }
Example #27
Source File: UnmodifiableMapIterator.java From Penetration_Testing_POC with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param iterator the iterator to decorate */ private UnmodifiableMapIterator(MapIterator iterator) { super(); this.iterator = iterator; }
Example #28
Source File: AbstractMapIteratorDecorator.java From Penetration_Testing_POC with Apache License 2.0 | 2 votes |
/** * Gets the iterator being decorated. * * @return the decorated iterator */ protected MapIterator getMapIterator() { return iterator; }
Example #29
Source File: AbstractReferenceMap.java From Penetration_Testing_POC with Apache License 2.0 | 2 votes |
/** * Gets a MapIterator over the reference map. * The iterator only returns valid key/value pairs. * * @return a map iterator */ public MapIterator mapIterator() { return new ReferenceMapIterator(this); }
Example #30
Source File: AbstractDualBidiMap.java From Penetration_Testing_POC with Apache License 2.0 | 2 votes |
/** * Obtains a <code>MapIterator</code> over the map. * The iterator implements <code>ResetableMapIterator</code>. * This implementation relies on the entrySet iterator. * <p> * The setValue() methods only allow a new value to be set. * If the value being set is already in the map, an IllegalArgumentException * is thrown (as setValue cannot change the size of the map). * * @return a map iterator */ public MapIterator mapIterator() { return new BidiMapIterator(this); }