Download jar file or use maven. psjava requires Java 1.6 (or above)
<dependency>
<groupId>org.psjava</groupId>
<artifactId>psjava</artifactId>
<version>0.1.19</version>
</dependency>
// Set is an read-only interface which is different from java.util.Set // MutableSet interface is modifiable. MutableSet<String> set1 = GoodMutableSetFactory.getInstance().create(); set1.add("A"); // 'add' method's parameter value is must not be exsit in the set set1.addIfAbsent("A"); // 'addIfAbsent' is more generous. set1.add("B"); set1.add("C"); int size = set1.size(); // must be 3 // You can insert many items at once. InsertAllToSet.insertAll(set1, VarargsIterable.create("X", "Y", "Z")); // You can simply create a set from values. Set<Integer> set2 = SetFromVarargs.create(1, 2, 3, 4);
Copyright 2014 psjava team. View on GitHub