use of org.apache.commons.collections.HashBag in project pancm_project by xuwujing.
the class collectionsTest method bagTest.
/**
* Bag 测试
* 主要测试重复元素的统计
*/
@SuppressWarnings("deprecation")
private static void bagTest() {
// 定义4种球
Bag box = new HashBag(Arrays.asList("red", "blue", "black", "green"));
// box.getCount():1
System.out.println("box.getCount():" + box.getCount("red"));
// 红色的球增加五个
box.add("red", 5);
// box.size():9
System.out.println("box.size():" + box.size());
// box.getCount():6
System.out.println("box.getCount():" + box.getCount("red"));
}
use of org.apache.commons.collections.HashBag in project pancm_project by xuwujing.
the class commonsTest method bagTest.
/**
* Bag 测试
* 主要测试重复元素的统计
*/
@SuppressWarnings("deprecation")
private static void bagTest() {
// 定义4种球
Bag box = new HashBag(Arrays.asList("red", "blue", "black", "green"));
// box.getCount():1
System.out.println("box.getCount():" + box.getCount("red"));
// 红色的球增加五个
box.add("red", 5);
// box.size():9
System.out.println("box.size():" + box.size());
// box.getCount():6
System.out.println("box.getCount():" + box.getCount("red"));
}