本文整理了Java中org.apache.commons.collections.Bag.remove()
方法的一些代码示例,展示了Bag.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bag.remove()
方法的具体详情如下:
包路径:org.apache.commons.collections.Bag
类名称:Bag
方法名:remove
英 Removes all occurrences of the given object from the bag.
This will also remove the object from the #uniqueSet().
According to the Collection#remove(Object) method, this method should only remove the first occurrence of the given object, not all occurrences.
[中](违例)从包中删除给定对象的所有引用。
这也将从#uniqueSet()中删除对象。
根据Collection#remove(Object)方法,此方法应仅删除给定对象的第一个匹配项,而不是所有匹配项。
代码示例来源:origin: commons-collections/commons-collections
public boolean remove(Object object, int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
}
代码示例来源:origin: commons-collections/commons-collections
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
代码示例来源:origin: commons-collections/commons-collections
public boolean remove(Object object, int nCopies) {
return getBag().remove(object, nCopies);
}
代码示例来源:origin: commons-collections/commons-collections
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
代码示例来源:origin: wildfly/wildfly
public boolean remove(Object object, int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
}
代码示例来源:origin: wildfly/wildfly
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
代码示例来源:origin: wildfly/wildfly
public boolean remove(Object object, int nCopies) {
return getBag().remove(object, nCopies);
}
代码示例来源:origin: wildfly/wildfly
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
代码示例来源:origin: commons-collections/commons-collections
public void testIteratorFail() {
Bag bag = makeBag();
bag.add("A");
bag.add("A");
bag.add("B");
Iterator it = bag.iterator();
it.next();
bag.remove("A");
try {
it.next();
fail("Should throw ConcurrentModificationException");
} catch (ConcurrentModificationException e) {
// expected
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testTransformedBag() {
Bag bag = TransformedBag.decorate(new HashBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, bag.size());
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) {
bag.add(els[i]);
assertEquals(i + 1, bag.size());
assertEquals(true, bag.contains(new Integer((String) els[i])));
assertEquals(false, bag.contains(els[i]));
}
assertEquals(false, bag.remove(els[0]));
assertEquals(true, bag.remove(new Integer((String) els[0])));
}
代码示例来源:origin: commons-collections/commons-collections
public void testTransformedBag() {
Bag bag = TransformedSortedBag.decorate(new TreeBag(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
assertEquals(0, bag.size());
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
for (int i = 0; i < els.length; i++) {
bag.add(els[i]);
assertEquals(i + 1, bag.size());
assertEquals(true, bag.contains(new Integer((String) els[i])));
}
assertEquals(true, bag.remove(new Integer((String) els[0])));
}
代码示例来源:origin: commons-collections/commons-collections
public void testRemove() {
Bag bag = makeBag();
bag.add("A");
assertEquals("Should have count of 1", 1, bag.getCount("A"));
bag.remove("A");
assertEquals("Should have count of 0", 0, bag.getCount("A"));
bag.add("A");
bag.add("A");
bag.add("A");
bag.add("A");
assertEquals("Should have count of 4", 4, bag.getCount("A"));
bag.remove("A", 0);
assertEquals("Should have count of 4", 4, bag.getCount("A"));
bag.remove("A", 2);
assertEquals("Should have count of 2", 2, bag.getCount("A"));
bag.remove("A");
assertEquals("Should have count of 0", 0, bag.getCount("A"));
}
代码示例来源:origin: commons-collections/commons-collections
public void testlegalAddRemove() {
Bag bag = makeTestBag();
assertEquals(0, bag.size());
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "1"};
for (int i = 0; i < els.length; i++) {
bag.add(els[i]);
assertEquals(i + 1, bag.size());
assertEquals(true, bag.contains(els[i]));
}
Set set = ((PredicatedBag) bag).uniqueSet();
assertTrue("Unique set contains the first element",set.contains(els[0]));
assertEquals(true, bag.remove(els[0]));
set = ((PredicatedBag) bag).uniqueSet();
assertTrue("Unique set now does not contain the first element",
!set.contains(els[0]));
}
代码示例来源:origin: commons-collections/commons-collections
public void testlegalAddRemove() {
Bag bag = makeTestBag();
assertEquals(0, bag.size());
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "1"};
for (int i = 0; i < els.length; i++) {
bag.add(els[i]);
assertEquals(i + 1, bag.size());
assertEquals(true, bag.contains(els[i]));
}
Set set = ((PredicatedBag) bag).uniqueSet();
assertTrue("Unique set contains the first element",set.contains(els[0]));
assertEquals(true, bag.remove(els[0]));
set = ((PredicatedBag) bag).uniqueSet();
assertTrue("Unique set now does not contain the first element",
!set.contains(els[0]));
}
代码示例来源:origin: commons-collections/commons-collections
public void testSize() {
Bag bag = makeBag();
assertEquals("Should have 0 total items", 0, bag.size());
bag.add("A");
assertEquals("Should have 1 total items", 1, bag.size());
bag.add("A");
assertEquals("Should have 2 total items", 2, bag.size());
bag.add("A");
assertEquals("Should have 3 total items", 3, bag.size());
bag.add("B");
assertEquals("Should have 4 total items", 4, bag.size());
bag.add("B");
assertEquals("Should have 5 total items", 5, bag.size());
bag.remove("A", 2);
assertEquals("Should have 1 'A'", 1, bag.getCount("A"));
assertEquals("Should have 3 total items", 3, bag.size());
bag.remove("B");
assertEquals("Should have 1 total item", 1, bag.size());
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public boolean remove(Object object, int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections
public boolean remove(Object object, int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
}
代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand
public boolean remove(Object object, int count) {
synchronized (lock) {
return getBag().remove(object, count);
}
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
public boolean remove(Object object, int nCopies) {
return getBag().remove(object, nCopies);
}
内容来源于网络,如有侵权,请联系作者删除!