CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-eclipse-collections--eclipse-collections-api

A comprehensive collections framework API for Java providing interfaces for object collections, primitive collections and lazy iterables

Pending
Overview
Eval results
Files

core-collections.mddocs/

Core Collections

Eclipse Collections provides four primary collection types: Lists (ordered, indexed), Sets (unique elements), Bags (multisets with occurrence counting), and Stacks (LIFO collections). Each type comes in mutable and immutable variants with comprehensive functional programming support.

// Required imports for types used in this documentation
import java.util.Random;
import java.util.function.Supplier;
import org.eclipse.collections.api.block.predicate.primitive.IntPredicate;

Lists

ListIterable<T>

The base interface for all list collections providing ordered, indexed access.

package org.eclipse.collections.api.list;

public interface ListIterable<T> extends RichIterable<T> {
    // Indexed access
    T get(int index);
    T getFirst();
    T getLast();
    int indexOf(Object object);
    int lastIndexOf(Object object);
    
    // Sublist operations
    ListIterable<T> subList(int fromIndex, int toIndex);
    ListIterable<T> take(int count);
    ListIterable<T> drop(int count);
    
    // List-specific transformations
    ListIterable<T> toReversed();
    ListIterable<T> distinct();
    
    // Functional operations returning Lists
    <V> ListIterable<V> collect(Function<? super T, ? extends V> function);
    ListIterable<T> select(Predicate<? super T> predicate);
    ListIterable<T> reject(Predicate<? super T> predicate);
    
    // Zipping operations
    <S> ListIterable<Pair<T, S>> zip(Iterable<S> that);
    ListIterable<Pair<T, Integer>> zipWithIndex();
    
    // Bi-directional iteration
    void forEachInBoth(ListIterable<T> other, Procedure2<? super T, ? super T> procedure);
    
    // Conversion
    MutableList<T> toList();
    ImmutableList<T> toImmutableList();
}

MutableList<T>

Mutable list implementation extending Java's List interface with Eclipse Collections enhancements.

package org.eclipse.collections.api.list;

public interface MutableList<T> extends MutableCollection<T>, List<T>, ListIterable<T> {
    // Modification operations
    MutableList<T> with(T element);
    MutableList<T> without(T element);
    MutableList<T> withAll(Iterable<? extends T> elements);
    MutableList<T> withoutAll(Iterable<? extends T> elements);
    
    // List-specific mutations
    MutableList<T> reverseThis();
    MutableList<T> sortThis();
    MutableList<T> sortThis(Comparator<? super T> comparator);
    MutableList<T> shuffleThis();
    MutableList<T> shuffleThis(Random rnd);
    
    // Functional transformations (in-place)
    <V> MutableList<V> collect(Function<? super T, ? extends V> function);
    MutableList<T> select(Predicate<? super T> predicate);
    MutableList<T> reject(Predicate<? super T> predicate);
    
    // Sublist operations
    MutableList<T> subList(int fromIndex, int toIndex);
    MutableList<T> take(int count);
    MutableList<T> drop(int count);
    
    // Immutable copy
    ImmutableList<T> toImmutable();
}

ImmutableList<T>

Thread-safe immutable list where all operations return new instances.

package org.eclipse.collections.api.list;

public interface ImmutableList<T> extends ListIterable<T> {
    // Modification operations return new instances
    ImmutableList<T> newWith(T element);
    ImmutableList<T> newWithout(T element);
    ImmutableList<T> newWithAll(Iterable<? extends T> elements);
    ImmutableList<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Functional transformations return new instances
    <V> ImmutableList<V> collect(Function<? super T, ? extends V> function);
    ImmutableList<T> select(Predicate<? super T> predicate);
    ImmutableList<T> reject(Predicate<? super T> predicate);
    
    // Sublist operations return new instances
    ImmutableList<T> subList(int fromIndex, int toIndex);
    ImmutableList<T> take(int count);
    ImmutableList<T> drop(int count);
    ImmutableList<T> toReversed();
    ImmutableList<T> distinct();
}

Sets

SetIterable<T>

Base interface for set collections with mathematical set operations.

package org.eclipse.collections.api.set;

public interface SetIterable<T> extends RichIterable<T> {
    // Mathematical set operations
    SetIterable<T> union(SetIterable<? extends T> set);
    SetIterable<T> intersect(SetIterable<? extends T> set);
    SetIterable<T> difference(SetIterable<? extends T> subtrahendSet);
    SetIterable<T> symmetricDifference(SetIterable<? extends T> setB);
    
    // Set relationships
    boolean isSubsetOf(SetIterable<? extends T> candidateSuperset);
    boolean isProperSubsetOf(SetIterable<? extends T> candidateSuperset);
    
    // Cartesian product
    <R extends Set<Pair<T, B>>, B> R cartesianProduct(
        SetIterable<B> set, 
        Supplier<R> setFactory
    );
    
    // Functional operations returning Sets
    <V> SetIterable<V> collect(Function<? super T, ? extends V> function);
    SetIterable<T> select(Predicate<? super T> predicate);
    SetIterable<T> reject(Predicate<? super T> predicate);
    
    // Conversion
    MutableSet<T> toSet();
    ImmutableSet<T> toImmutableSet();
}

MutableSet<T>

Mutable set implementation with Eclipse Collections enhancements.

package org.eclipse.collections.api.set;

public interface MutableSet<T> extends MutableCollection<T>, Set<T>, SetIterable<T> {
    // Modification operations
    MutableSet<T> with(T element);
    MutableSet<T> without(T element);
    MutableSet<T> withAll(Iterable<? extends T> elements);
    MutableSet<T> withoutAll(Iterable<? extends T> elements);
    
    // Mathematical set operations (mutating)
    MutableSet<T> unionInPlace(SetIterable<? extends T> set);
    MutableSet<T> intersectInPlace(SetIterable<? extends T> set);
    MutableSet<T> differenceInPlace(SetIterable<? extends T> subtrahendSet);
    MutableSet<T> symmetricDifferenceInPlace(SetIterable<? extends T> setB);
    
    // Mathematical set operations (new instances)
    MutableSet<T> union(SetIterable<? extends T> set);
    MutableSet<T> intersect(SetIterable<? extends T> set);
    MutableSet<T> difference(SetIterable<? extends T> subtrahendSet);
    MutableSet<T> symmetricDifference(SetIterable<? extends T> setB);
    
    // Functional operations
    <V> MutableSet<V> collect(Function<? super T, ? extends V> function);
    MutableSet<T> select(Predicate<? super T> predicate);
    MutableSet<T> reject(Predicate<? super T> predicate);
    
    // Immutable copy
    ImmutableSet<T> toImmutable();
}

ImmutableSet<T>

Thread-safe immutable set where all operations return new instances.

package org.eclipse.collections.api.set;

public interface ImmutableSet<T> extends SetIterable<T> {
    // Modification operations return new instances
    ImmutableSet<T> newWith(T element);
    ImmutableSet<T> newWithout(T element);
    ImmutableSet<T> newWithAll(Iterable<? extends T> elements);
    ImmutableSet<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Mathematical set operations return new instances
    ImmutableSet<T> union(SetIterable<? extends T> set);
    ImmutableSet<T> intersect(SetIterable<? extends T> set);
    ImmutableSet<T> difference(SetIterable<? extends T> subtrahendSet);
    ImmutableSet<T> symmetricDifference(SetIterable<? extends T> setB);
    
    // Functional operations return new instances
    <V> ImmutableSet<V> collect(Function<? super T, ? extends V> function);
    ImmutableSet<T> select(Predicate<? super T> predicate);
    ImmutableSet<T> reject(Predicate<? super T> predicate);
}

Bags

Bag<T>

Multiset collection that allows duplicates and provides occurrence counting.

package org.eclipse.collections.api.bag;

public interface Bag<T> extends RichIterable<T> {
    // Occurrence operations
    int occurrencesOf(Object item);
    void forEachWithOccurrences(ObjectIntProcedure<? super T> procedure);
    
    // Occurrence-based operations
    Bag<T> selectByOccurrences(IntPredicate predicate);
    Map<T, Integer> toMapOfItemToCount();
    
    // Bag-specific operations
    int sizeDistinct();
    Bag<T> topOccurrences(int count);
    Bag<T> bottomOccurrences(int count);
    
    // Functional operations returning Bags
    <V> Bag<V> collect(Function<? super T, ? extends V> function);
    Bag<T> select(Predicate<? super T> predicate);
    Bag<T> reject(Predicate<? super T> predicate);
    
    // Conversion
    MutableBag<T> toBag();
    ImmutableBag<T> toImmutableBag();
}

MutableBag<T>

Mutable bag implementation with occurrence manipulation.

package org.eclipse.collections.api.bag;

public interface MutableBag<T> extends MutableBagIterable<T>, Bag<T> {
    // Occurrence-based modifications
    boolean addOccurrences(T item, int occurrences);
    boolean removeOccurrences(Object item, int occurrences);
    boolean setOccurrences(T item, int occurrences);
    
    // Modification operations
    MutableBag<T> with(T element);
    MutableBag<T> without(T element);
    MutableBag<T> withAll(Iterable<? extends T> elements);
    MutableBag<T> withoutAll(Iterable<? extends T> elements);
    
    // Functional operations
    <V> MutableBag<V> collect(Function<? super T, ? extends V> function);
    MutableBag<T> select(Predicate<? super T> predicate);
    MutableBag<T> reject(Predicate<? super T> predicate);
    
    // Occurrence-based operations
    MutableBag<T> selectByOccurrences(IntPredicate predicate);
    
    // Immutable copy
    ImmutableBag<T> toImmutable();
}

ImmutableBag<T>

Thread-safe immutable bag where all operations return new instances.

package org.eclipse.collections.api.bag;

public interface ImmutableBag<T> extends Bag<T> {
    // Modification operations return new instances
    ImmutableBag<T> newWith(T element);
    ImmutableBag<T> newWithout(T element);
    ImmutableBag<T> newWithAll(Iterable<? extends T> elements);
    ImmutableBag<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Occurrence operations return new instances
    ImmutableBag<T> newWithOccurrences(T item, int occurrences);
    ImmutableBag<T> newWithoutOccurrences(Object item, int occurrences);
    
    // Functional operations return new instances
    <V> ImmutableBag<V> collect(Function<? super T, ? extends V> function);
    ImmutableBag<T> select(Predicate<? super T> predicate);
    ImmutableBag<T> reject(Predicate<? super T> predicate);
    ImmutableBag<T> selectByOccurrences(IntPredicate predicate);
}

Stacks

StackIterable<T>

LIFO (Last-In-First-Out) collection interface with stack-specific operations.

package org.eclipse.collections.api.stack;

public interface StackIterable<T> extends OrderedIterable<T> {
    // Stack access operations
    T peek();
    T peekAt(int index);
    
    // Stack-specific queries
    ListIterable<T> peek(int count);
    
    // Stack-specific functional operations
    boolean allSatisfyFromTop(Predicate<? super T> predicate, int count);
    boolean anySatisfyFromTop(Predicate<? super T> predicate, int count);
    int countFromTop(Predicate<? super T> predicate, int count);
    
    // Functional operations returning Stacks
    <V> StackIterable<V> collect(Function<? super T, ? extends V> function);
    StackIterable<T> select(Predicate<? super T> predicate);
    StackIterable<T> reject(Predicate<? super T> predicate);
    
    // Conversion
    MutableStack<T> toStack();
    ImmutableStack<T> toImmutableStack();
}

MutableStack<T>

Mutable stack implementation with LIFO operations.

package org.eclipse.collections.api.stack;

public interface MutableStack<T> extends MutableCollection<T>, StackIterable<T> {
    // Stack modification operations
    void push(T item);
    T pop();
    ListIterable<T> pop(int count);
    void clear();
    
    // Modification operations
    MutableStack<T> with(T element);
    MutableStack<T> without(T element);
    MutableStack<T> withAll(Iterable<? extends T> elements);
    MutableStack<T> withoutAll(Iterable<? extends T> elements);
    
    // Functional operations
    <V> MutableStack<V> collect(Function<? super T, ? extends V> function);
    MutableStack<T> select(Predicate<? super T> predicate);
    MutableStack<T> reject(Predicate<? super T> predicate);
    
    // Immutable copy
    ImmutableStack<T> toImmutable();
}

ImmutableStack<T>

Thread-safe immutable stack where all operations return new instances.

package org.eclipse.collections.api.stack;

public interface ImmutableStack<T> extends StackIterable<T> {
    // Stack operations return new instances
    ImmutableStack<T> push(T item);
    ImmutableStack<T> pop();
    ImmutableStack<T> pop(int count);
    
    // Modification operations return new instances
    ImmutableStack<T> newWith(T element);
    ImmutableStack<T> newWithout(T element);
    ImmutableStack<T> newWithAll(Iterable<? extends T> elements);
    ImmutableStack<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Functional operations return new instances
    <V> ImmutableStack<V> collect(Function<? super T, ? extends V> function);
    ImmutableStack<T> select(Predicate<? super T> predicate);
    ImmutableStack<T> reject(Predicate<? super T> predicate);
}

Usage Examples

Working with Lists

// Create and manipulate lists
MutableList<String> names = Lists.mutable.with("Alice", "Bob", "Charlie");
names.add("David");

// List-specific operations
String first = names.getFirst(); // "Alice"
String last = names.getLast();   // "David"
int index = names.indexOf("Bob"); // 1

// Functional operations
MutableList<String> filtered = names.select(name -> name.length() > 3);
MutableList<Integer> lengths = names.collect(String::length);

// Immutable operations
ImmutableList<String> immutableNames = names.toImmutable();
ImmutableList<String> withNew = immutableNames.newWith("Eve");

Working with Sets

// Create sets
MutableSet<Integer> set1 = Sets.mutable.with(1, 2, 3);
MutableSet<Integer> set2 = Sets.mutable.with(3, 4, 5);

// Mathematical operations
MutableSet<Integer> union = set1.union(set2);        // {1, 2, 3, 4, 5}
MutableSet<Integer> intersect = set1.intersect(set2); // {3}
MutableSet<Integer> diff = set1.difference(set2);     // {1, 2}

// Set relationships
boolean isSubset = set1.isSubsetOf(union); // true

Working with Bags

// Create bag with duplicates
MutableBag<String> words = Bags.mutable.with("hello", "world", "hello", "java");

// Occurrence operations
int count = words.occurrencesOf("hello"); // 2
words.addOccurrences("hello", 3);         // now has 5 "hello"s

// Occurrence-based filtering
MutableBag<String> frequent = words.selectByOccurrences(count -> count > 1);

Working with Stacks

// Create and manipulate stack
MutableStack<String> stack = Stacks.mutable.empty();
stack.push("first");
stack.push("second");
stack.push("third");

// Stack operations
String top = stack.peek();    // "third"
String popped = stack.pop();  // "third", removes from stack
ListIterable<String> top2 = stack.peek(2); // ["second", "first"]

Sorted Collections

Eclipse Collections provides sorted variants of Sets and Bags that maintain elements in sorted order according to their natural ordering or a provided Comparator.

SortedSetIterable<T>

Base interface for sorted sets extending both SetIterable and SortedIterable.

package org.eclipse.collections.api.set.sorted;

public interface SortedSetIterable<T> extends SetIterable<T>, SortedIterable<T> {
    // Sorted-specific access
    T first();
    T last();
    
    // Range operations
    SortedSetIterable<T> takeWhile(Predicate<? super T> predicate);
    SortedSetIterable<T> dropWhile(Predicate<? super T> predicate);
    
    // Subset operations
    SortedSetIterable<T> subSet(T fromElement, T toElement);
    SortedSetIterable<T> headSet(T toElement);
    SortedSetIterable<T> tailSet(T fromElement);
    
    // Functional operations returning sorted sets
    <V> SortedSetIterable<V> collect(Function<? super T, ? extends V> function);
    SortedSetIterable<T> select(Predicate<? super T> predicate);
    SortedSetIterable<T> reject(Predicate<? super T> predicate);
    
    // Conversion
    MutableSortedSet<T> toSortedSet();
    ImmutableSortedSet<T> toImmutableSortedSet();
}

MutableSortedSet<T>

Mutable sorted set implementation extending Java's SortedSet interface.

package org.eclipse.collections.api.set.sorted;

public interface MutableSortedSet<T> extends MutableSet<T>, SortedSet<T>, SortedSetIterable<T> {
    // Modification operations
    MutableSortedSet<T> with(T element);
    MutableSortedSet<T> without(T element);
    MutableSortedSet<T> withAll(Iterable<? extends T> elements);
    MutableSortedSet<T> withoutAll(Iterable<? extends T> elements);
    
    // Functional operations
    <V> MutableSortedSet<V> collect(Function<? super T, ? extends V> function);
    MutableSortedSet<T> select(Predicate<? super T> predicate);
    MutableSortedSet<T> reject(Predicate<? super T> predicate);
    
    // Range operations
    MutableSortedSet<T> subSet(T fromElement, T toElement);
    MutableSortedSet<T> headSet(T toElement);
    MutableSortedSet<T> tailSet(T fromElement);
    
    // Immutable copy
    ImmutableSortedSet<T> toImmutable();
}

ImmutableSortedSet<T>

Thread-safe immutable sorted set where all operations return new instances.

package org.eclipse.collections.api.set.sorted;

public interface ImmutableSortedSet<T> extends SortedSetIterable<T> {
    // Modification operations return new instances
    ImmutableSortedSet<T> newWith(T element);
    ImmutableSortedSet<T> newWithout(T element);
    ImmutableSortedSet<T> newWithAll(Iterable<? extends T> elements);
    ImmutableSortedSet<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Functional operations return new instances
    <V> ImmutableSortedSet<V> collect(Function<? super T, ? extends V> function);
    ImmutableSortedSet<T> select(Predicate<? super T> predicate);
    ImmutableSortedSet<T> reject(Predicate<? super T> predicate);
    
    // Range operations return new instances
    ImmutableSortedSet<T> subSet(T fromElement, T toElement);
    ImmutableSortedSet<T> headSet(T toElement);
    ImmutableSortedSet<T> tailSet(T fromElement);
}

SortedBag<T>

Base interface for sorted bags (multisets) that maintain elements in sorted order.

package org.eclipse.collections.api.bag.sorted;

public interface SortedBag<T> extends Bag<T>, SortedIterable<T> {
    // Sorted-specific access
    T first();
    T last();
    
    // Range operations
    SortedBag<T> takeWhile(Predicate<? super T> predicate);
    SortedBag<T> dropWhile(Predicate<? super T> predicate);
    
    // Functional operations returning sorted bags
    <V> SortedBag<V> collect(Function<? super T, ? extends V> function);
    SortedBag<T> select(Predicate<? super T> predicate);
    SortedBag<T> reject(Predicate<? super T> predicate);
    SortedBag<T> selectByOccurrences(IntPredicate predicate);
    
    // Conversion
    MutableSortedBag<T> toSortedBag();
    ImmutableSortedBag<T> toImmutableSortedBag();
}

MutableSortedBag<T>

Mutable sorted bag implementation with occurrence counting in sorted order.

package org.eclipse.collections.api.bag.sorted;

public interface MutableSortedBag<T> extends MutableBag<T>, SortedBag<T> {
    // Occurrence-based modifications
    boolean addOccurrences(T item, int occurrences);
    boolean removeOccurrences(Object item, int occurrences);
    boolean setOccurrences(T item, int occurrences);
    
    // Modification operations
    MutableSortedBag<T> with(T element);
    MutableSortedBag<T> without(T element);
    MutableSortedBag<T> withAll(Iterable<? extends T> elements);
    MutableSortedBag<T> withoutAll(Iterable<? extends T> elements);
    
    // Functional operations
    <V> MutableSortedBag<V> collect(Function<? super T, ? extends V> function);
    MutableSortedBag<T> select(Predicate<? super T> predicate);
    MutableSortedBag<T> reject(Predicate<? super T> predicate);
    MutableSortedBag<T> selectByOccurrences(IntPredicate predicate);
    
    // Immutable copy
    ImmutableSortedBag<T> toImmutable();
}

ImmutableSortedBag<T>

Thread-safe immutable sorted bag where all operations return new instances.

package org.eclipse.collections.api.bag.sorted;

public interface ImmutableSortedBag<T> extends SortedBag<T> {
    // Modification operations return new instances
    ImmutableSortedBag<T> newWith(T element);
    ImmutableSortedBag<T> newWithout(T element);
    ImmutableSortedBag<T> newWithAll(Iterable<? extends T> elements);
    ImmutableSortedBag<T> newWithoutAll(Iterable<? extends T> elements);
    
    // Occurrence operations return new instances
    ImmutableSortedBag<T> newWithOccurrences(T item, int occurrences);
    ImmutableSortedBag<T> newWithoutOccurrences(Object item, int occurrences);
    
    // Functional operations return new instances
    <V> ImmutableSortedBag<V> collect(Function<? super T, ? extends V> function);
    ImmutableSortedBag<T> select(Predicate<? super T> predicate);
    ImmutableSortedBag<T> reject(Predicate<? super T> predicate);
    ImmutableSortedBag<T> selectByOccurrences(IntPredicate predicate);
}

Working with Sorted Collections

// Create sorted collections
MutableSortedSet<String> sortedSet = SortedSets.mutable.with("zebra", "apple", "banana");
// Elements are automatically sorted: ["apple", "banana", "zebra"]

// Range operations
SortedSetIterable<String> subset = sortedSet.subSet("apple", "zebra");
SortedSetIterable<String> headSet = sortedSet.headSet("banana"); // ["apple"]

// Sorted bags with duplicates
MutableSortedBag<Integer> sortedBag = SortedBags.mutable.with(3, 1, 4, 1, 5);
// Elements maintain sort order: [1, 1, 3, 4, 5]

// Occurrence operations preserve sorting
sortedBag.addOccurrences(2, 3); // [1, 1, 2, 2, 2, 3, 4, 5]

Install with Tessl CLI

npx tessl i tessl/maven-org-eclipse-collections--eclipse-collections-api

docs

core-collections.md

factories-utilities.md

functional-interfaces.md

index.md

maps-multimaps.md

primitive-collections.md

tile.json