本文整理汇总了Java中com.google.common.collect.ForwardingSet类的典型用法代码示例。如果您正苦于以下问题:Java ForwardingSet类的具体用法?Java ForwardingSet怎么用?Java ForwardingSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ForwardingSet类属于com.google.common.collect包,在下文中一共展示了ForwardingSet类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformEntries
import com.google.common.collect.ForwardingSet; //导入依赖的package包/类
static <K, V> Set<Entry<K, V>> transformEntries(final Set<Entry<K, V>> entries) {
return new ForwardingSet<Map.Entry<K, V>>() {
@Override
protected Set<Entry<K, V>> delegate() {
return entries;
}
@Override
public Iterator<Entry<K, V>> iterator() {
return UnmodifiableEntry.transformEntries(super.iterator());
}
@Override
public Object[] toArray() {
return standardToArray();
}
@Override
public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
};
}
示例2: transformEntries
import com.google.common.collect.ForwardingSet; //导入依赖的package包/类
static <K, V> Set<Entry<K, V>> transformEntries(final Set<Entry<K, V>> entries) {
return new ForwardingSet<Map.Entry<K, V>>() {
@Override protected Set<Entry<K, V>> delegate() {
return entries;
}
@Override public Iterator<Entry<K, V>> iterator() {
return UnmodifiableEntry.transformEntries(super.iterator());
}
@Override public Object[] toArray() {
return standardToArray();
}
@Override public <T> T[] toArray(T[] array) {
return standardToArray(array);
}
};
}
示例3: removeOnlySet
import com.google.common.collect.ForwardingSet; //导入依赖的package包/类
private static <E> Set<E> removeOnlySet(final Set<E> set) {
return new ForwardingSet<E>() {
@Override protected Set<E> delegate() {
return set;
}
@Override public boolean add(E element) {
throw new UnsupportedOperationException();
}
@Override public boolean addAll(Collection<? extends E> es) {
throw new UnsupportedOperationException();
}
};
}
示例4: newThreadLocalSet
import com.google.common.collect.ForwardingSet; //导入依赖的package包/类
public static <T> Set<T> newThreadLocalSet() {
return new ForwardingSet<T>() {
private final ThreadLocal<Set<T>> threadSet = new ThreadLocal<Set<T>>() {
@Override
protected Set<T> initialValue() {
return Sets.newHashSet();
}
};
@Override
protected Set<T> delegate() {
return threadSet.get();
}
};
}