eaLib API Docs
Last Modified : January 7 2002

mss.ea.core
Class ListUtil

java.lang.Object
  |
  +--mss.ea.core.ListUtil

public class ListUtil
extends java.lang.Object

Helper for the work with lists. The original code was written by Mark Lindner (frenzy@ix.netcom.com) and was part of the Kiwi Toolkit (http://www.dystance.net/ping/kiwi) which is licensed under GPL. The code is changed to provide the possibility to work with all data structures implementing the list interface.

Since:
0.1
Version:
0.1
Author:
Andreas Rummler

Field Summary
protected static java.util.Comparator comp
          Comparator.
 
Constructor Summary
ListUtil()
           
 
Method Summary
static java.util.List append(java.util.List l1, java.util.List l2)
          Appends a list to a second one.
static java.lang.Object binarySearch(java.util.List l, java.lang.Object o)
          Binary search through a list.
static boolean compare(java.util.List l1, java.util.List l2, boolean sorted)
          Compares two lists.
static void difference(java.util.List l1, java.util.List l2, java.util.List target, boolean sorted)
          Difference of two lists.
static boolean equals(java.util.List a0, java.util.List a1)
          Compares two lists for equality.
static void intersection(java.util.List l1, java.util.List l2, java.util.List target, boolean sorted)
          Intersection of two lists.
static java.lang.Object linearSearch(java.util.List l, java.lang.Object o)
          Linear search through a list.
static void merge(java.util.List l1, java.util.List l2, java.util.List target, boolean sorted)
          Merges two lists.
static void searchMultiple(java.util.List l, java.util.List target)
          Searches for multiple objects in a list.
static int searchPosition(java.util.List l, java.lang.Object o)
          Linear search for the position of an object.
static int searchPosition(java.util.List l, java.lang.Object o, int startPosition)
          Linear search for the position of an object in a list segment.
static void setComparator(java.util.Comparator c)
          Sets a new comparator.
static void union(java.util.List l1, java.util.List l2, java.util.List target, boolean sorted)
          Union of two lists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected static java.util.Comparator comp
Comparator. Element of a list are compared using this comparator. The default is a HashCodeComparator.
Constructor Detail

ListUtil

public ListUtil()
Method Detail

setComparator

public static void setComparator(java.util.Comparator c)
Sets a new comparator.
Parameters:
c - new comparator

append

public static java.util.List append(java.util.List l1,
                                    java.util.List l2)
Appends a list to a second one.
Parameters:
l1 - list to append to
l2 - list to be appended
Returns:
new list

binarySearch

public static java.lang.Object binarySearch(java.util.List l,
                                            java.lang.Object o)
Binary search through a list. The list must be sorted or the behaviour of this method is undefined.
Parameters:
l - list to be searched
o - object to search for
Returns:
the object to found found or null

compare

public static boolean compare(java.util.List l1,
                              java.util.List l2,
                              boolean sorted)
Compares two lists. The comparison checks if every object of one list are contained in the other one.
Parameters:
l1 - first list
l2 - second list
sorted - flag to indicate whether the both lists are sorted
Returns:
result of the comparison

linearSearch

public static java.lang.Object linearSearch(java.util.List l,
                                            java.lang.Object o)
Linear search through a list.
Parameters:
l - list to search through
o - object to search for
Returns:
the object to search for of null instead

searchMultiple

public static void searchMultiple(java.util.List l,
                                  java.util.List target)
Searches for multiple objects in a list.
Parameters:
l - list to search
target - list to put found multiple objects in

searchPosition

public static int searchPosition(java.util.List l,
                                 java.lang.Object o)
Linear search for the position of an object.
Parameters:
l - list to search through
o - object to search for
Returns:
position of the object or -1 instead

searchPosition

public static int searchPosition(java.util.List l,
                                 java.lang.Object o,
                                 int startPosition)
Linear search for the position of an object in a list segment.
Parameters:
l - list to search through
o - object to search for
startPosition - starting position
Returns:
position of the object or -1 instead

difference

public static void difference(java.util.List l1,
                              java.util.List l2,
                              java.util.List target,
                              boolean sorted)
Difference of two lists. The difference of two list contains all elements of the first list that are not contained in the second one.
Parameters:
l1 - first list
l2 - second list
target - list to put the difference in
sorted - flag to indicate if both lists are sorted

intersection

public static void intersection(java.util.List l1,
                                java.util.List l2,
                                java.util.List target,
                                boolean sorted)
Intersection of two lists. The intersection contains all elements that are contained in both lists.
Parameters:
l1 - first list
l2 - second list
target - list to put intersection in
sorted - flag to indicate whether both list are sorted

merge

public static void merge(java.util.List l1,
                         java.util.List l2,
                         java.util.List target,
                         boolean sorted)
Merges two lists. The merged list contains all elements of both list exactly once.
Parameters:
l1 - first list
l2 - second list
target - list to put result in
sorted - flag to indicate whether both lists are sorted

union

public static void union(java.util.List l1,
                         java.util.List l2,
                         java.util.List target,
                         boolean sorted)
Union of two lists. The union contains all elements that are contained in only one of the two lists.
Parameters:
l1 - first list
l2 - second list
target - list to put the union in
sorted - flag to indicate whether both lists are sorted

equals

public static boolean equals(java.util.List a0,
                             java.util.List a1)
Compares two lists for equality.
Parameters:
a0 - first list
a1 - second list
Returns:
result of comparison

eaLib API Docs
Last Modified : January 7 2002

Copyright © 2000-2001 Technical University of Ilmenau, Department ESS