public final class KCollections extends Object
Modifier | Constructor and Description |
---|---|
private |
KCollections() |
Modifier and Type | Method and Description |
---|---|
static Collection |
add(Collection c1,
Collection c2)
Add the elements from one collection to another collection.
|
static boolean |
compare(List l1,
List l2,
boolean sorted,
Comparator comparator)
Compare two lists.
|
static List |
difference(List l1,
List l2,
boolean sorted,
Comparator comparator)
Compute the difference between two lists.
|
static List |
intersection(List l1,
List l2,
boolean sorted,
Comparator comparator)
Compute the intersection of two lists.
|
static int |
linearSearch(Collection c,
Object o,
Comparator comparator)
Perform a linear search on a collection.
|
static void |
print(Collection c)
Print the contents of a collection.
|
static int |
search(List l,
Object o,
boolean sorted,
Comparator comparator)
Search for an object in a list.
|
static List |
union(List l1,
List l2,
boolean sorted,
Comparator comparator)
Compute the union of two lists.
|
private KCollections()
public static void print(Collection c)
c
- The collection to print.public static int search(List l, Object o, boolean sorted, Comparator comparator)
l
- The list to search.o
- The object to search for.sorted
- A flag specifying whether the list is sorted.comparator
- The comparator to use.-1
if not found.public static int linearSearch(Collection c, Object o, Comparator comparator)
c
- The collection to search.o
- The object to search for.comparator
- The comparator to use.-1
if not found.public static boolean compare(List l1, List l2, boolean sorted, Comparator comparator)
l1
- The first list.l2
- The second list.sorted
- A flag specifying whether the lists are sorted.comparator
- The comparator to use.true
if the lists are "equal" and
false
otherwise.public static List union(List l1, List l2, boolean sorted, Comparator comparator)
l1
- The first list.l2
- The second list.sorted
- A flag specifying whether the lists are sorted.comparator
- The comparator to use.l1
and all
items in l2
that are not also in l1
.public static List intersection(List l1, List l2, boolean sorted, Comparator comparator)
l1
- The first vector.l2
- The second vector.sorted
- A flag specifying whether the lists are sorted.comparator
- The comparator to use.l1
and l2
.public static List difference(List l1, List l2, boolean sorted, Comparator comparator)
l1
- The first list.l2
- The second list.sorted
- A flag specifying whether the lists are sorted.comparator
- The comparator to use.l1
that are
not in l2
.public static Collection add(Collection c1, Collection c2)
c1
- The original collection.c2
- The collection of items to add to c1
.c1
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses