Eclipse Collections - Features you want with the collections you need.
//Initializing mutable list with empty(), of(), with() method
MutableList<String> mutableListEmpty =
Lists.mutable.empty();
MutableList<String> mutableListOf =
Lists.mutable.of("One", "One", "Two", "Three");
MutableList<String> mutableListWith =
Lists.mutable.with("One", "One", "Two", "Three");
//Various container types available
MutableSet<String> mutableSet =
Sets.mutable.with("One", "One", "Two", "Three");
MutableBag<String> mutableBag =
Bags.mutable.with("One", "One", "Two", "Three");
MutableStack<String> mutableStack =
Stacks.mutable.with("One", "One", "Two", "Three");
MutableMap<String, String> mutableMap =
Maps.mutable.with("key1", "value1", "key2", "value2", "key3", "value3");
MutableMultimap<String, String> multimapWithList =
Multimaps.mutable.list.with("key1", "value1-1", "key1", "value1-2", "key2","value2-1");
MutableBiMap<String, String> mutableBiMap =
BiMaps.mutable.with("key1", "value1", "key2", "value2", "key3", "value3");
//Initializing immutable list with empty(), of(), with() method
ImmutableList<String> immutableListEmpty =
Lists.immutable.empty();
ImmutableList<String> immutableListOf =
Lists.immutable.of("One", "One", "Two", "Three");
ImmutableList<String> immutableListWith =
Lists.immutable.with("One", "One", "Two", "Three");
//Various container types available
ImmutableSet<String> immutableSet =
Sets.immutable.with("One", "One", "Two", "Three");
ImmutableBag<String> immutableBag =
Bags.immutable.with("One", "One", "Two", "Three");
ImmutableStack<String> immutableStack =
Stacks.immutable.with("One", "One", "Two", "Three");
ImmutableMap<String, String> immutableMap =
Maps.immutable.with("key1", "value1", "key2", "value2", "key3", "value3");
ImmutableMultimap<String, String> immutableMultimapWithList =
Multimaps.immutable.list.with("key1", "value1-1", "key1", "value1-2", "key2","value2-1");
ImmutableBiMap<String, String> immutableBiMap =
BiMaps.immutable.with("key1", "value1", "key2", "value2", "key3", "value3");
//Mutable and immutable Lists, Sets, Bags, Stacks and Maps are available for all 8 primitive types
MutableIntList intList =
IntLists.mutable.of(1, 2, 3);
MutableLongList longList =
LongLists.mutable.of(1L, 2L, 3L);
MutableCharList charList =
CharLists.mutable.of('a', 'b', 'c');
MutableShortList shortList =
ShortLists.mutable.of((short)1, (short)2, (short)3);
MutableByteList byteList =
ByteLists.mutable.of((byte)1, (byte)2, (byte)3);
MutableBooleanList booleanList =
BooleanLists.mutable.of(true, false);
MutableFloatList floatList =
FloatLists.mutable.of(1.0f, 2.0f, 3.0f);
MutableDoubleList doubleList =
DoubleLists.mutable.of(1.0, 2.0, 3.0);
//You can create a ranged ints with IntInterval
IntInterval oneTo10 =
IntInterval.fromTo(1, 10); // ints from 1 to 10
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
IntInterval oneTo10By3 =
IntInterval.fromToBy(1, 10, 3); // ints from 1 to 10 step by 3
// [1, 4, 7, 10]
IntInterval oddsFrom1To10 =
IntInterval.oddsFromTo(1, 10); // odd ints from 1 to 10
// [1, 3, 5, 7, 9]
IntInterval evensFrom1To10 =
IntInterval.evensFromTo(1, 10); // even ints from 1 to 10
// [2, 4, 6, 8, 10]