-
Notifications
You must be signed in to change notification settings - Fork 1
BoostList
BoostList is based on ArrayList. But it provides you the different way to loop or manipulate the elements in a list, and also convert the list to map structure. For example, if you want to loop on each element in string list, the traditional way is
for (String str : stringList) {
System.out.println(str);
}
But for BoostList, you can do it like:
stringBoostList.foreach(new VoidFunction<String>() {
public void call(String str) {
System.out.println(str);
}
});
Return a new BoostList containing only the elements that satisfy a predicate.
Return a new BoostList by applying a function to all elements of this BoostList.
Return a new BoostList by first applying a function to all elements of this BoostList, and then flattening the results.
BoostList<String> list = new BoostList<String>();
list.add("apple,tree,car,king");
list.add("open,door,window,run");
list.add("high,small,tall,computer,team");
BoostList<String> newList = list.flatMap(new FlatMapFunction<String, String>() {
public Iterable<String> call(String s) {
return Arrays.asList(s.split(",")); // split one element into multiple elements
}
});
So the new list will have: "apple", "tree", "car", "king", "open", "door", "window", "run", "high", "small", "tall", "computer", "team".
Return a new BoostMap by applying a transforming function to all elements of this BoostList.
Remove duplicates. This is based on equals() to identify the same elements.
Produce an BoostList containing elements from both.
Return a BoostList containing only elements found in both 2 BoostLists.
{1,2,3}.intersection({3,4,5}) = {3}
Remove the contents of one BoostList.
{1,2,3}.subtract({3,4,5}) = {1,2}
Return the Cartesian product (all ordered pairs) of 2 BoostLists.
{a,b,c}.cartesian({x,y,z}) = {(a,x),(a,y),(a,z),(b,x),(b,y),(b,z),(c,x),(c,y),(c,z)}
Applies a function to all elements of this BoostList. It is the alteration of for-loop.
Convert a BoostList into a normal ArrayList.
Return the number of elements in the BoostList.
Return the count of each unique value in this BoostList as a map of (value, count) pairs.
{a,d,a,b,b,e,r,e,a}.countByValue() = {(a,3),(b,1),(d,1),(e,2),(r,1)}
Take the first N elements of this BoostList.