本文整理汇总了Java中java.util.AbstractSet类的典型用法代码示例。如果您正苦于以下问题:Java AbstractSet类的具体用法?Java AbstractSet怎么用?Java AbstractSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractSet类属于java.util包,在下文中一共展示了AbstractSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public Set<Map.Entry<NameAndAccess, TMember>> entrySet() {
return new AbstractSet<Map.Entry<NameAndAccess, TMember>>() {
@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();
}
};
}
示例2: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public Set<Entry<Range<K>, V>> entrySet() {
return new AbstractSet<Entry<Range<K>, V>>() {
@SuppressWarnings("unchecked") // it's safe to upcast iterators
@Override
public Iterator<Entry<Range<K>, V>> iterator() {
return (Iterator) entriesByLowerBound.values().iterator();
}
@Override
public int size() {
return entriesByLowerBound.size();
}
};
}
示例3: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public Set<Map.Entry<K, V>> entrySet() {
return new AbstractSet<Map.Entry<K, V>>() {
@Override
public Iterator<java.util.Map.Entry<K, V>> iterator() {
return new EntryIterator<>(root);
}
@Override
public boolean contains(Object o) {
if (o == null || !(o instanceof Map.Entry)) {
return false;
}
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>) o;
return entry.getValue().equals(CopyOnWriteHashMap.this.get(entry.getKey()));
}
@Override
public int size() {
return CopyOnWriteHashMap.this.size();
}
};
}
示例4: broadcast
import java.util.AbstractSet; //导入依赖的package包/类
/**
* {@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();
}
};
}
示例5: commandRun
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public void commandRun() {
if (zkServer == null) {
pw.println(ZK_NOT_SERVING);
} else {
// clone should be faster than iteration
// ie give up the cnxns lock faster
AbstractSet<ServerCnxn> cnxns;
synchronized (factory.cnxns) {
cnxns = new HashSet<ServerCnxn>(factory.cnxns);
}
for (ServerCnxn c : cnxns) {
c.dumpConnectionInfo(pw, false);
pw.println();
}
pw.println();
}
}
示例6: keySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public Set<K> keySet()
{
return new AbstractSet()
{
@Override
public Iterator iterator()
{
return iterableKeys.iterator();
}
@Override
public int size()
{
return iterableKeys.size();
}
};
}
示例7: asHashSet
import java.util.AbstractSet; //导入依赖的package包/类
/**
* 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>() {
public boolean contains(Object o) {
return hashBinarySearch(array, o) >= 0;
}
public Iterator<T> iterator() {
return iterate(array);
}
public int size() {
return array.length;
}
};
}
示例8: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@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();
}
};
}
示例9: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@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;
}
};
}
示例10: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
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);
}
};
}
示例11: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override
@SuppressWarnings ("unchecked")
public Set<java.util.Map.Entry<K, V>> entrySet() {
if (entries == null) {
entries = new AbstractSet<Entry<K, V>>() {
@Override
public void clear() {
throw new UnsupportedOperationException();
}
@Override
public Iterator<Entry<K, V>> iterator() {
return list.iterator();
}
@Override
public int size() {
return list.size();
}
};
}
return (Set<java.util.Map.Entry<K, V>>) entries;
}
示例12: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@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;
}
};
}
示例13: entrySet
import java.util.AbstractSet; //导入依赖的package包/类
@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);
}
};
}
示例14: keySet
import java.util.AbstractSet; //导入依赖的package包/类
@Override synchronized public Set<K> keySet() {
return new AbstractSet<K>() {
@Override public int size() {
return OidEntityDtoMap.this.size();
}
@Override public boolean contains(Object o) {
return OidEntityDtoMap.this.containsKey(o);
}
@Override public Iterator<K> iterator() {
return OidEntityDtoMap.this.keys_.iterator();
}
};
}
示例15: commandRun
import java.util.AbstractSet; //导入依赖的package包/类
@Override
public void commandRun() {
if (!isZKServerRunning()) {
pw.println(ZK_NOT_SERVING);
} else {
// clone should be faster than iteration
// ie give up the cnxns lock faster
AbstractSet<ServerCnxn> cnxns;
synchronized (factory.cnxns) {
cnxns = new HashSet<ServerCnxn>(factory.cnxns);
}
for (ServerCnxn c : cnxns) {
c.dumpConnectionInfo(pw, false);
pw.println();
}
pw.println();
}
}