/** Overridden for the same reason than {@link AbstractMap#equals(Object). */ @Override public boolean equals(final Object object) { if (object == this) { return true; } if (!(object instanceof Set<?>)) { return false; } final Set<?> that = (Set<?>) object; final EntryIterator<K,V> it = entryIterator(); if (it == null) { return that.isEmpty(); } int size = 0; while (it.next()) { if (!that.contains(it.getEntry())) { return false; } size++; } return size == that.size(); } };
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */ @Override public boolean equals(final Object object) { if (object == this) { return true; } if (!(object instanceof Set<?>)) { return false; } final Set<?> that = (Set<?>) object; final EntryIterator<K,V> it = entryIterator(); if (it == null) { return that.isEmpty(); } int size = 0; while (it.next()) { if (!that.contains(it.getKey())) { return false; } size++; } return size == that.size(); } };
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */ @Override public boolean equals(final Object object) { if (object == this) { return true; } if (!(object instanceof Set<?>)) { return false; } final Set<?> that = (Set<?>) object; final EntryIterator<K,V> it = entryIterator(); if (it == null) { return that.isEmpty(); } int size = 0; while (it.next()) { if (!that.contains(it.getEntry())) { return false; } size++; } return size == that.size(); } };
while (it.next()) { if (!it.getValue().equals(that.get(it.getKey()))) { return false;
while (it.next()) { if (!it.getValue().equals(that.get(it.getKey()))) { return false;
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */ @Override public boolean equals(final Object object) { if (object == this) { return true; } if (!(object instanceof Set<?>)) { return false; } final Set<?> that = (Set<?>) object; final EntryIterator<K,V> it = entryIterator(); if (it == null) { return that.isEmpty(); } int size = 0; while (it.next()) { if (!that.contains(it.getKey())) { return false; } size++; } return size == that.size(); } };
/** * Returns a string representation of this map. The default implementation is different than the * {@code java.util.AbstractMap} one, as it uses a tabular format rather than formatting all entries * on a single line. * * @return a string representation of this map. */ @Override public String toString() { final TableAppender buffer = new TableAppender(" = "); buffer.setMultiLinesCells(true); final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { buffer.append(String.valueOf(it.getKey())); buffer.nextColumn(); buffer.append(AbstractMapEntry.firstLine(it.getValue())); buffer.nextLine(); } return buffer.toString(); } }
/** * Returns {@code true} if this map contains the given value. * The default implementation iterates over all values using the {@link #entryIterator()}. * * @param value the value for which to test the presence. * @return {@code true} if the map contains the given value. */ @Override public boolean containsValue(final Object value) { final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { if (it.getValue().equals(value)) { return true; } } return false; }
/** * Returns a string representation of this map. The default implementation is different than the * {@code java.util.AbstractMap} one, as it uses a tabular format rather than formatting all entries * on a single line. * * @return a string representation of this map. */ @Override public String toString() { final TableAppender buffer = new TableAppender(" = "); buffer.setMultiLinesCells(true); final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { buffer.append(String.valueOf(it.getKey())); buffer.nextColumn(); buffer.append(AbstractMapEntry.firstLine(it.getValue())); buffer.nextLine(); } return buffer.toString(); } }
/** * Returns {@code true} if this map contains the given value. * The default implementation iterates over all values using the {@link #entryIterator()}. * * @param value the value for which to test the presence. * @return {@code true} if the map contains the given value. */ @Override public boolean containsValue(final Object value) { final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { if (it.getValue().equals(value)) { return true; } } return false; }
/** * Computes a hash code value for this map. * * @return a hash code value. */ @Override public int hashCode() { int code = 0; final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { code += (Objects.hashCode(it.getKey()) ^ Objects.hashCode(it.getValue())); } return code; }
/** * Returns {@code true} if there is at least one more element to return. */ public final boolean hasNext() { switch (hasNext) { case TRUE: return true; case FALSE: return false; default: { final boolean c = iterator.next(); hasNext = c ? TRUE : FALSE; return c; } } }
/** * Returns {@code true} if there is at least one more element to return. */ public final boolean hasNext() { switch (hasNext) { case TRUE: return true; case FALSE: return false; default: { final boolean c = iterator.next(); hasNext = c ? TRUE : FALSE; return c; } } }
/** * Computes a hash code value for this map. * * @return a hash code value. */ @Override public int hashCode() { int code = 0; final EntryIterator<K,V> it = entryIterator(); if (it != null) while (it.next()) { code += (Objects.hashCode(it.getKey()) ^ Objects.hashCode(it.getValue())); } return code; }
/** * Returns the number of key-value mappings in this map. * The default implementation count the number of values returned by {@link #entryIterator()}. * Subclasses should implement a more efficient method. */ @Override public int size() { int count = 0; for (final EntryIterator<K,V> it = entryIterator(); it.next();) { if (++count == Integer.MAX_VALUE) break; } return count; }
/** * Returns {@code true} if this map contains no element. * * @return {@code true} if this map contains no element. */ @Override public boolean isEmpty() { return !entryIterator().next(); }
/** * Returns the number of key-value mappings in this map. * The default implementation count the number of values returned by {@link #entryIterator()}. * Subclasses should implement a more efficient method. */ @Override public int size() { int count = 0; for (final EntryIterator<K,V> it = entryIterator(); it.next();) { if (++count == Integer.MAX_VALUE) break; } return count; }
/** * Returns {@code true} if this map contains no element. * * @return {@code true} if this map contains no element. */ @Override public boolean isEmpty() { return !entryIterator().next(); }