java.util.AbstractSet Java Examples
The following examples show how to use
java.util.AbstractSet.
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: ReflectionClassDef.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull @Override public Set<String> getInterfaces() { return new AbstractSet<String>() { @Nonnull @Override public Iterator<String> iterator() { return Iterators.transform(Iterators.forArray(cls.getInterfaces()), new Function<Class, String>() { @Nullable @Override public String apply(@Nullable Class input) { if (input == null) { return null; } return ReflectionUtils.javaToDexName(input.getName()); } }); } @Override public int size() { return cls.getInterfaces().length; } }; }
Example #2
Source File: Util.java From Bats with Apache License 2.0 | 6 votes |
/** Returns a map that is a view onto a collection of values, using the * provided function to convert a value to a key. * * <p>Unlike * {@link com.google.common.collect.Maps#uniqueIndex(Iterable, com.google.common.base.Function)}, * returns a view whose contents change as the collection of values changes. * * @param values Collection of values * @param function Function to map value to key * @param <K> Key type * @param <V> Value type * @return Map that is a view onto the values */ public static <K, V> Map<K, V> asIndexMapJ( final Collection<V> values, final Function<V, K> function) { final Collection<Map.Entry<K, V>> entries = Collections2.transform(values, v -> Pair.of(function.apply(v), v)); final Set<Map.Entry<K, V>> entrySet = new AbstractSet<Map.Entry<K, V>>() { public Iterator<Map.Entry<K, V>> iterator() { return entries.iterator(); } public int size() { return entries.size(); } }; return new AbstractMap<K, V>() { public Set<Entry<K, V>> entrySet() { return entrySet; } }; }
Example #3
Source File: ImmutableBitSet.java From Bats with Apache License 2.0 | 6 votes |
/** Creates a view onto this bit set as a set of integers. * * <p>The {@code size} and {@code contains} methods are both O(n), but the * iterator is efficient. */ public Set<Integer> asSet() { return new AbstractSet<Integer>() { public Iterator<Integer> iterator() { return ImmutableBitSet.this.iterator(); } public int size() { return cardinality(); } @Override public boolean contains(Object o) { return ImmutableBitSet.this.get((Integer) o); } }; }
Example #4
Source File: Defaults.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public Set<Map.Entry<K, V>> entrySet() { return new AbstractSet<Map.Entry<K, V>>() { public int size() { return map.size(); } public Iterator<Map.Entry<K,V>> iterator() { final Iterator<Map.Entry<K,V>> source = map.entrySet().iterator(); return new Iterator<Map.Entry<K,V>>() { public boolean hasNext() { return source.hasNext(); } public Map.Entry<K,V> next() { return source.next(); } public void remove() { source.remove(); } }; } public boolean add(Map.Entry<K,V> e) { return map.entrySet().add(e); } }; }
Example #5
Source File: Util.java From Quicksql with MIT License | 6 votes |
/** Returns a map that is a view onto a collection of values, using the * provided function to convert a value to a key. * * <p>Unlike * {@link com.google.common.collect.Maps#uniqueIndex(Iterable, com.google.common.base.Function)}, * returns a view whose contents change as the collection of values changes. * * @param values Collection of values * @param function Function to map value to key * @param <K> Key type * @param <V> Value type * @return Map that is a view onto the values */ public static <K, V> Map<K, V> asIndexMapJ( final Collection<V> values, final Function<V, K> function) { final Collection<Map.Entry<K, V>> entries = Collections2.transform(values, v -> Pair.of(function.apply(v), v)); final Set<Map.Entry<K, V>> entrySet = new AbstractSet<Map.Entry<K, V>>() { public Iterator<Map.Entry<K, V>> iterator() { return entries.iterator(); } public int size() { return entries.size(); } }; return new AbstractMap<K, V>() { public Set<Entry<K, V>> entrySet() { return entrySet; } }; }
Example #6
Source File: NbtFactory.java From AdditionsAPI with MIT License | 6 votes |
@Override public Set<Entry<String, Object>> entrySet() { return new AbstractSet<Entry<String,Object>>() { @Override public boolean add(Entry<String, Object> e) { String key = e.getKey(); Object value = e.getValue(); original.put(key, unwrapIncoming(value)); return true; } @Override public int size() { return original.size(); } @Override public Iterator<Entry<String, Object>> iterator() { return ConvertedMap.this.iterator(); } }; }
Example #7
Source File: ImmutableBitSet.java From Quicksql with MIT License | 6 votes |
/** Creates a view onto this bit set as a set of integers. * * <p>The {@code size} and {@code contains} methods are both O(n), but the * iterator is efficient. */ public Set<Integer> asSet() { return new AbstractSet<Integer>() { @Nonnull public Iterator<Integer> iterator() { return ImmutableBitSet.this.iterator(); } public int size() { return cardinality(); } @Override public boolean contains(Object o) { return ImmutableBitSet.this.get((Integer) o); } }; }
Example #8
Source File: Defaults.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<K,V>> entrySet() { return new AbstractSet<Map.Entry<K,V>>() { @Override public int size() { return map.size(); } @Override public Iterator<Map.Entry<K,V>> iterator() { final Iterator<Map.Entry<K,V>> source = map.entrySet().iterator(); return new Iterator<Map.Entry<K,V>>() { public boolean hasNext() { return source.hasNext(); } public Map.Entry<K,V> next() { return source.next(); } public void remove() { source.remove(); } }; } @Override public boolean add(Map.Entry<K,V> e) { return map.entrySet().add(e); } }; }
Example #9
Source File: Collectors.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #10
Source File: Collectors.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return List.of(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #11
Source File: Collectors.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #12
Source File: Defaults.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public Set<Map.Entry<K, V>> entrySet() { return new AbstractSet<Map.Entry<K, V>>() { public int size() { return map.size(); } public Iterator<Map.Entry<K,V>> iterator() { final Iterator<Map.Entry<K,V>> source = map.entrySet().iterator(); return new Iterator<Map.Entry<K,V>>() { public boolean hasNext() { return source.hasNext(); } public Map.Entry<K,V> next() { return source.next(); } public void remove() { source.remove(); } }; } public boolean add(Map.Entry<K,V> e) { return map.entrySet().add(e); } }; }
Example #13
Source File: Collectors.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #14
Source File: Containers.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * Returns a set backed by the given array (i.e. a set that uses object equality * for comparisons). The array must contain no duplicates, its elements must be * sorted in the increasing order of hashcodes (as by * {@link #hashSort(Object[])}), and its contents must not be changed while it * is in use by the returned set. * * @requires all i, j: [0..array.length) | i < j => array[i].hashCode() <= * array[j].hashCode * @return an unmodifiable Set view of the given array */ public static final <T> Set<T> asHashSet(final T[] array) { return new AbstractSet<T>() { @Override public boolean contains(Object o) { return hashBinarySearch(array, o) >= 0; } @Override public Iterator<T> iterator() { return iterate(array); } @Override public int size() { return array.length; } }; }
Example #15
Source File: AbstractIoService.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ public final Set<WriteFuture> broadcast(Object message) { // Convert to Set. We do not return a List here because only the // direct caller of MessageBroadcaster knows the order of write // operations. final List<WriteFuture> futures = IoUtil.broadcast(message, getManagedSessions().values()); return new AbstractSet<WriteFuture>() { @Override public Iterator<WriteFuture> iterator() { return futures.iterator(); } @Override public int size() { return futures.size(); } }; }
Example #16
Source File: Model.java From smithy with Apache License 2.0 | 6 votes |
/** * Converts the model to an immutable Set of shapes. * * @return Returns an unmodifiable set of shapes. */ public Set<Shape> toSet() { return new AbstractSet<Shape>() { @Override public int size() { return shapeMap.size(); } @Override public boolean contains(Object o) { return o instanceof Shape && shapeMap.containsKey(((Shape) o).getId()); } @Override public Iterator<Shape> iterator() { return shapeMap.values().iterator(); } }; }
Example #17
Source File: ReflectionClassDef.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull @Override public Set<? extends Field> getFields() { return new AbstractSet<Field>() { @Nonnull @Override public Iterator<Field> iterator() { return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()), new Function<java.lang.reflect.Field, Field>() { @Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) { return new ReflectionField(input); } }); } @Override public int size() { return cls.getDeclaredFields().length; } }; }
Example #18
Source File: MemberByNameAndAccessMap.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public Set<Map.Entry<NameAndAccess, TMember>> entrySet() { return new AbstractSet<>() { @Override public Iterator<Map.Entry<NameAndAccess, TMember>> iterator() { return Iterators.unmodifiableIterator( new TransformedIterator2<TMember, Map.Entry<NameAndAccess, TMember>>(members.iterator()) { @Override protected Map.Entry<NameAndAccess, TMember> transform(TMember input) { final NameAndAccess[] nameAndAccess = NameAndAccess.of(input); if (nameAndAccess.length > 1) { setAdditionalElement( new AbstractMap.SimpleImmutableEntry<>(nameAndAccess[1], input)); } return new AbstractMap.SimpleImmutableEntry<>(nameAndAccess[0], input); } }); } @Override public int size() { return members.size(); } }; }
Example #19
Source File: Collectors.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #20
Source File: Defaults.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public Set<Map.Entry<K, V>> entrySet() { return new AbstractSet<Map.Entry<K, V>>() { public int size() { return map.size(); } public Iterator<Map.Entry<K,V>> iterator() { final Iterator<Map.Entry<K,V>> source = map.entrySet().iterator(); return new Iterator<Map.Entry<K,V>>() { public boolean hasNext() { return source.hasNext(); } public Map.Entry<K,V> next() { return source.next(); } public void remove() { source.remove(); } }; } public boolean add(Map.Entry<K,V> e) { return map.entrySet().add(e); } }; }
Example #21
Source File: Defaults.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public Set<Map.Entry<K, V>> entrySet() { return new AbstractSet<Map.Entry<K, V>>() { public int size() { return map.size(); } public Iterator<Map.Entry<K,V>> iterator() { final Iterator<Map.Entry<K,V>> source = map.entrySet().iterator(); return new Iterator<Map.Entry<K,V>>() { public boolean hasNext() { return source.hasNext(); } public Map.Entry<K,V> next() { return source.next(); } public void remove() { source.remove(); } }; } public boolean add(Map.Entry<K,V> e) { return map.entrySet().add(e); } }; }
Example #22
Source File: Collectors.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #23
Source File: Collectors.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #24
Source File: Collectors.java From desugar_jdk_libs with GNU General Public License v2.0 | 6 votes |
@Override public Set<Map.Entry<Boolean, T>> entrySet() { return new AbstractSet<Map.Entry<Boolean, T>>() { @Override public Iterator<Map.Entry<Boolean, T>> iterator() { Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse); Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue); return Arrays.asList(falseEntry, trueEntry).iterator(); } @Override public int size() { return 2; } }; }
Example #25
Source File: FileScope.java From gyro with Apache License 2.0 | 6 votes |
@Override public Set<String> keySet() { return new AbstractSet<String>() { @Override public void clear() { FileScope.this.clear(); } @Override public Iterator<String> iterator() { return FileScope.super.keySet().iterator(); } @Override public int size() { return FileScope.super.keySet().size(); } }; }
Example #26
Source File: PrestoMap.java From transport with BSD 2-Clause "Simplified" License | 6 votes |
public Set<StdData> keySet() { return new AbstractSet<StdData>() { @Override public Iterator<StdData> iterator() { return new Iterator<StdData>() { int i = -2; @Override public boolean hasNext() { return !(i + 2 == size() * 2); } @Override public StdData next() { i += 2; return PrestoWrapper.createStdData(readNativeValue(_keyType, _block, i), _keyType, _stdFactory); } }; } @Override public int size() { return PrestoMap.this.size(); } }; }
Example #27
Source File: GenericMap.java From transport with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Set<StdData> keySet() { return new AbstractSet<StdData>() { @Override public Iterator<StdData> iterator() { return new Iterator<StdData>() { Iterator<Object> keySet = _map.keySet().iterator(); @Override public boolean hasNext() { return keySet.hasNext(); } @Override public StdData next() { return GenericWrapper.createStdData(keySet.next(), _keyType); } }; } @Override public int size() { return _map.size(); } }; }
Example #28
Source File: HiveMap.java From transport with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Set<StdData> keySet() { return new AbstractSet<StdData>() { @Override public Iterator<StdData> iterator() { return new Iterator<StdData>() { Iterator mapKeyIterator = _mapObjectInspector.getMap(_object).keySet().iterator(); @Override public boolean hasNext() { return mapKeyIterator.hasNext(); } @Override public StdData next() { return HiveWrapper.createStdData(mapKeyIterator.next(), _keyObjectInspector, _stdFactory); } }; } @Override public int size() { return HiveMap.this.size(); } }; }
Example #29
Source File: AvroMap.java From transport with BSD 2-Clause "Simplified" License | 6 votes |
@Override public Set<StdData> keySet() { return new AbstractSet<StdData>() { @Override public Iterator<StdData> iterator() { return new Iterator<StdData>() { Iterator<Object> keySet = _map.keySet().iterator(); @Override public boolean hasNext() { return keySet.hasNext(); } @Override public StdData next() { return AvroWrapper.createStdData(keySet.next(), _keySchema); } }; } @Override public int size() { return _map.size(); } }; }
Example #30
Source File: FileScope.java From gyro with Apache License 2.0 | 6 votes |
@Override public Set<Entry<String, Object>> entrySet() { return new AbstractSet<Entry<String, Object>>() { @Override public void clear() { FileScope.this.clear(); } @Override public Iterator<Map.Entry<String, Object>> iterator() { return FileScope.super.entrySet().iterator(); } @Override public int size() { return FileScope.super.entrySet().size(); } }; }