本文整理汇总了Java中java.util.AbstractCollection类的典型用法代码示例。如果您正苦于以下问题:Java AbstractCollection类的具体用法?Java AbstractCollection怎么用?Java AbstractCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractCollection类属于java.util包,在下文中一共展示了AbstractCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkOnAbsentFalsePositive
import java.util.AbstractCollection; //导入依赖的package包/类
private void checkOnAbsentFalsePositive(int hashId, int numInsertions,
final RetouchedBloomFilter filter, Digits digits, short removeSchema) {
AbstractCollection<Key> falsePositives = FALSE_POSITIVE_UNDER_1000
.get(hashId);
if (falsePositives == null)
Assert.fail(String.format("false positives for hash %d not founded",
hashId));
filter.addFalsePositive(falsePositives);
for (int i = digits.getStart(); i < numInsertions; i += 2) {
filter.add(new Key(Integer.toString(i).getBytes()));
}
for (Key key : falsePositives) {
filter.selectiveClearing(key, removeSchema);
}
for (int i = 1 - digits.getStart(); i < numInsertions; i += 2) {
assertFalse(" testRetouchedBloomFilterAddFalsePositive error " + i,
filter.membershipTest(new Key(Integer.toString(i).getBytes())));
}
}
示例2: test_addAllLjava_util_Collection
import java.util.AbstractCollection; //导入依赖的package包/类
/**
* @tests java.util.AbstractCollection#addAll(java.util.Collection)
*/
public void test_addAllLjava_util_Collection() {
final Collection<String> fixtures = Arrays.asList("0", "1", "2");
AbstractCollection<String> ac = new AbstractCollection<String>() {
@Override
public boolean add(String object) {
assertTrue(fixtures.contains(object));
return true;
}
@Override
public Iterator<String> iterator() {
fail("iterator should not get called");
return null;
}
@Override
public int size() {
fail("size should not get called");
return 0;
}
};
assertTrue(ac.addAll(fixtures));
}
示例3: testContextStartup
import java.util.AbstractCollection; //导入依赖的package包/类
/**
* Check context startup and shutdown
*/
public void testContextStartup() throws Exception
{
getConfiguration(TreeSet.class);
getConfiguration(HashSet.class);
getConfiguration(ArrayList.class);
getConfiguration(AbstractCollection.class);
try
{
getConfiguration(Collection.class);
fail("Failed to detect incompatible class hierarchy");
}
catch (Throwable e)
{
// Expected
}
}
示例4: values
import java.util.AbstractCollection; //导入依赖的package包/类
@Override
public Collection<Object> values() {
return new AbstractCollection<Object>() {
@Override
public Iterator<Object> iterator() {
return ImmutableObjectMap.this.keySet().stream().map(key -> ImmutableObjectMap.this.get(key))
.iterator();
}
@Override
public int size() {
return fieldMap.size();
}
};
}
示例5: htmlForObject
import java.util.AbstractCollection; //导入依赖的package包/类
protected String htmlForObject(Object obj) {
StringBuffer sb = new StringBuffer();
if (obj != null){
if (GeneralHtml.class.isInstance(obj)) {
sb.append(((GeneralHtml) obj).toHtml());
} else if (AbstractCollection.class.isInstance(obj)) {
Iterator colIt = ((AbstractCollection) obj).iterator();
while(colIt.hasNext()) {
sb.append(this.htmlForObject(colIt.next()));
}
} else {
sb.append(obj.toString());
}
}
return(sb.toString());
}
示例6: a
import java.util.AbstractCollection; //导入依赖的package包/类
private static Collection<Object> a(Class<?> cls, Type type) {
if (cls == AbstractCollection.class) {
return new ArrayList();
}
if (cls.isAssignableFrom(HashSet.class)) {
return new HashSet();
}
if (cls.isAssignableFrom(LinkedHashSet.class)) {
return new LinkedHashSet();
}
if (cls.isAssignableFrom(TreeSet.class)) {
return new TreeSet();
}
if (cls.isAssignableFrom(ArrayList.class)) {
return new ArrayList();
}
if (cls.isAssignableFrom(EnumSet.class)) {
return EnumSet.noneOf(type instanceof ParameterizedType ? ((ParameterizedType) type).getActualTypeArguments()[0] : Object.class);
}
try {
return (Collection) cls.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("create instane error, class " + cls.getName());
}
}
示例7: values
import java.util.AbstractCollection; //导入依赖的package包/类
@Override
public Collection<V> values() {
return new AbstractCollection<V>() {
@Override
public void clear() {
ExpiringMap.this.clear();
}
@Override
public boolean contains(Object value) {
return containsValue(value);
}
@Override
public Iterator<V> iterator() {
return (entries instanceof EntryLinkedHashMap) ? ((EntryLinkedHashMap<K, V>) entries).new ValueIterator()
: ((EntryTreeHashMap<K, V>) entries).new ValueIterator();
}
@Override
public int size() {
return ExpiringMap.this.size();
}
};
}
示例8: functional
import java.util.AbstractCollection; //导入依赖的package包/类
/** Returns a collection view of the values from this
<code>BijMap</code>. The view is fully functional (i.e.,
allows mutation) and connected to this bijective map (i.e.,
changes in one of them are reflected in the other one). */
public Collection<B> values() {
return new AbstractCollection<B>() {
public int size() { return map.size(); }
public Iterator<B> iterator() {
return
DSUtil.<Map.Entry<A,B>,B>mapIterator
(BijMap.this.entrySet().iterator(),
new Function<Map.Entry<A,B>,B>() {
public B f(Map.Entry<A,B> entry) {
return entry.getValue();
}
});
}
public boolean remove(Object b) {
return BijMap.this.rev().remove(b) != null;
}
public void clear() {
BijMap.this.clear();
}
};
}
示例9: values
import java.util.AbstractCollection; //导入依赖的package包/类
/** Returns an unmodifiable collection view of the values from this map. */
public final Collection<V> values() {
return new AbstractCollection<V>() {
public Iterator<V> iterator() {
final Iterator<Map.Entry<K,V>> ite = entryIterator();
return new Iterator<V>() {
public boolean hasNext() { return ite.hasNext(); }
public void remove() { ite.remove(); }
public V next() { return ite.next().getValue(); }
};
}
public int size() {
return size;
}
};
}
示例10: collection
import java.util.AbstractCollection; //导入依赖的package包/类
private <V> Collection<V> collection(final boolean forwards, final Function<Cell, V> f)
{
final Holder ref = this.ref;
return new AbstractCollection<V>()
{
public Iterator<V> iterator()
{
return Iterators.transform(BTree.<Cell>slice(ref.tree, forwards), f);
}
public int size()
{
return BTree.slice(ref.tree, true).count();
}
};
}
示例11: getFields
import java.util.AbstractCollection; //导入依赖的package包/类
@Nonnull
@Override
public Collection<? extends ImmutableField> getFields() {
return new AbstractCollection<ImmutableField>() {
@Nonnull
@Override
public Iterator<ImmutableField> iterator() {
return Iterators.concat(staticFields.iterator(), instanceFields.iterator());
}
@Override
public int size() {
return staticFields.size() + instanceFields.size();
}
};
}
示例12: getMethods
import java.util.AbstractCollection; //导入依赖的package包/类
@Nonnull
@Override
public Collection<? extends ImmutableMethod> getMethods() {
return new AbstractCollection<ImmutableMethod>() {
@Nonnull
@Override
public Iterator<ImmutableMethod> iterator() {
return Iterators.concat(directMethods.iterator(), virtualMethods.iterator());
}
@Override
public int size() {
return directMethods.size() + virtualMethods.size();
}
};
}
示例13: getStaticInitializers
import java.util.AbstractCollection; //导入依赖的package包/类
@Nullable
@Override
public Collection<? extends EncodedValue> getStaticInitializers(
@Nonnull PoolClassDef classDef) {
final SortedSet<Field> sortedStaticFields = classDef.getStaticFields();
final int lastIndex = CollectionUtils.lastIndexOf(sortedStaticFields, HAS_INITIALIZER);
if (lastIndex > -1) {
return new AbstractCollection<EncodedValue>() {
@Nonnull
@Override
public Iterator<EncodedValue> iterator() {
return FluentIterable.from(sortedStaticFields)
.limit(lastIndex + 1)
.transform(GET_INITIAL_VALUE).iterator();
}
@Override
public int size() {
return lastIndex + 1;
}
};
}
return null;
}
示例14: getFields
import java.util.AbstractCollection; //导入依赖的package包/类
@Nonnull
@Override
public Collection<Field> getFields() {
return new AbstractCollection<Field>() {
@Nonnull
@Override
public Iterator<Field> iterator() {
return Iterators.mergeSorted(
ImmutableList.of(staticFields.iterator(), instanceFields.iterator()),
Ordering.natural());
}
@Override
public int size() {
return staticFields.size() + instanceFields.size();
}
};
}
示例15: getMethods
import java.util.AbstractCollection; //导入依赖的package包/类
@Nonnull
@Override
public Collection<PoolMethod> getMethods() {
return new AbstractCollection<PoolMethod>() {
@Nonnull
@Override
public Iterator<PoolMethod> iterator() {
return Iterators.mergeSorted(
ImmutableList.of(directMethods.iterator(), virtualMethods.iterator()),
Ordering.natural());
}
@Override
public int size() {
return directMethods.size() + virtualMethods.size();
}
};
}