當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractCollection類代碼示例

本文整理匯總了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())));
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:25,代碼來源:TestBloomFilters.java

示例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));
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:29,代碼來源:AbstractCollectionTest.java

示例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
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:20,代碼來源:HierarchicalSqlSessionFactoryBeanTest.java

示例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();
        }

    };
}
 
開發者ID:primeval-io,項目名稱:primeval-reflex,代碼行數:18,代碼來源:ImmutableObjectMap.java

示例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());
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:GeneralHtml.java

示例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());
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:26,代碼來源:b.java

示例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();
    }
  };
}
 
開發者ID:ProtocolSupport,項目名稱:ProtocolSupportPocketStuff,代碼行數:26,代碼來源:ExpiringMap.java

示例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();
    }
};
   }
 
開發者ID:protegeproject,項目名稱:jpaul,代碼行數:26,代碼來源:BijMap.java

示例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;
    }
};
   }
 
開發者ID:protegeproject,項目名稱:jpaul,代碼行數:17,代碼來源:NoCompTreeMap.java

示例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();
        }
    };
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:17,代碼來源:AtomicBTreeColumns.java

示例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();
        }
    };
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:17,代碼來源:ImmutableClassDef.java

示例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();
        }
    };
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:17,代碼來源:ImmutableClassDef.java

示例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;
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:26,代碼來源:ClassPool.java

示例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();
        }
    };
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:19,代碼來源:PoolClassDef.java

示例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();
        }
    };
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:19,代碼來源:PoolClassDef.java


注:本文中的java.util.AbstractCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。