TapIntList

public final class TapIntList

List of int’s, simply chained forward.

Fields

tail

public TapIntList tail

The tail of this list.

Constructors

TapIntList

public TapIntList(int head, TapIntList tail)

Creates a new list cell with given “head” and “tail”.

Methods

add

public static TapIntList add(TapIntList list, int value)

Returns list with value added if not already present

addIntoSorted

public static TapIntList addIntoSorted(TapIntList list, int elem)

Add a new int “elem” into the (already sorted) given list.

addOffset

public static TapIntList addOffset(TapIntList list, int offset)
Returns

a copy of “list” with each number increased with “offset”.

append

public static TapIntList append(TapIntList list1, TapIntList list2)
Returns

a new TapIntList, concatenation of “list1” followed by “list2”. Caution: the result shares structure with “list2”.

appendIfAbsent

public final void appendIfAbsent(int n)

Adds n at the end of this list iff it is not already there.

contains

public static boolean contains(TapIntList list, int val)
Returns

true if value “val” is found in the given “list”.

contains

public static boolean contains(TapIntList list, TapIntList vals)
Returns

true if all given “vals” are contained in the given “list”.

copy

public static TapIntList copy(TapIntList list)
Returns

a copy of the given list.

dump

public void dump()

Prints the contents of this TapIntList onto TapEnv.curOutputStream().

equalLists

public static boolean equalLists(TapIntList list1, TapIntList list2)

intersection

public static TapIntList intersection(TapIntList list, TapIntList interList)
Returns

the intersection of “list” and “interList”. Caution: “list” may be modified and the result shares structure with “list”.

intersects

public static boolean intersects(TapIntList list1, TapIntList list2)
Returns

true if “list1” and “list2” have at least one int in common.

length

public static int length(TapIntList list)
Returns

the length of current list. Returns 0 if list is null.

maxElem

public static int maxElem(TapIntList list)
Returns

the maximal element of “list”, and -1 if list is empty.

minElem

public static int minElem(TapIntList list)
Returns

the minimal element of “list”, and -1 if list is empty.

minus

public static TapIntList minus(TapIntList list, TapIntList minusList)
Returns

“list” without elements in “minusList”. Caution: “list” may be modified and the result shares structure with “list”.

newR

public void newR(int val)

Adds new int “val” at the tail of this list.

placdl

public TapIntList placdl(int n)

Replaces the tail of this list by a new list cell, whose head is “n”, and whose tail is the previous tail of this list.

Returns

this new list cell.

quickUnion

public static TapIntList quickUnion(TapIntList list1, TapIntList list2)
Returns

the union of “list1” and “list2”. Does not add elements of list2 that are already in list1.

remove

public static TapIntList remove(TapIntList list, int value)

Returns list with value removed if present

removeAbove

public static TapIntList removeAbove(TapIntList list, int max)

Returns a copy of list, without all elements above max

reverse

public static TapIntList reverse(TapIntList list)
Returns

a reversed copy of the given “list”.

sort

public static TapIntList sort(TapIntList list)
Returns

a sorted (increasing order) copy of the given list.

sortedContains

public static boolean sortedContains(TapIntList list1, TapIntList list2)
Returns

true if “list1” contains “list2”. Both list1 and list2 must be sorted from 0 up, otherwise result is undefined.

sortedIntersects

public static boolean sortedIntersects(TapIntList list1, TapIntList list2)
Returns

true if “list1” intersects “list2”. Both list1 and list2 must be sorted from 0 up, otherwise result is undefined.

toString

public String toString()

union

public static TapIntList union(TapIntList list1, TapIntList list2)
Returns

a new list, concatenation of “list1” followed by “list2”, with duplicates removed.