Package art.cutils.collection
Class ListPartition<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<List<? super T>>
-
- art.cutils.collection.ListPartition<T>
-
- All Implemented Interfaces:
Iterable<List<? super T>>
,Collection<List<? super T>>
,List<List<? super T>>
public final class ListPartition<T> extends AbstractList<List<? super T>>
This class provides a means to partition List into List of sublist.- Since:
- 1.0
- Author:
- Szymon Stepniak, , Bobai Kato
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
@NotNull List<T>
get(int index)
int
hashCode()
ListPartition<T>
into(int sublistSize)
Method used to get partition size.static <T> @NotNull ListPartition<T>
of(List<? extends T> list)
Method to receive the list to be partitioned.static <T> @NotNull ListPartition<T>
of(T... array)
Method to receive the array to be partitioned.int
size()
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
of
@Contract("_ -> new") @NotNull public static <T> @NotNull ListPartition<T> of(List<? extends T> list)
Method to receive the list to be partitioned.- Type Parameters:
T
- List type- Parameters:
list
- List to be partitioned.- Returns:
- instance of
ListPartition
-
of
@SafeVarargs @Contract("_ -> new") @NotNull public static <T> @NotNull ListPartition<T> of(T... array)
Method to receive the array to be partitioned.- Type Parameters:
T
- Array type- Parameters:
array
- Array to be partitioned.- Returns:
- instance of
ListPartition
-
into
@Contract(value="_ -> this", mutates="this") public ListPartition<T> into(int sublistSize)
Method used to get partition size.- Parameters:
sublistSize
- The sub-list/ListPartition size.- Returns:
- current instance of
ListPartition
-
size
public int size()
- Specified by:
size
in interfaceCollection<T>
- Specified by:
size
in interfaceList<T>
- Specified by:
size
in classAbstractCollection<List<? super T>>
-
equals
@Contract(value="null -> false", pure=true) public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<T>
- Specified by:
equals
in interfaceList<T>
- Overrides:
equals
in classAbstractList<List<? super T>>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<T>
- Specified by:
hashCode
in interfaceList<T>
- Overrides:
hashCode
in classAbstractList<List<? super T>>
-
-