This project has the sole purpose to have methods in a collection (list, array, set enumerable) with similar methods (or extension method).
It retrieves notions from Javascript, Java, Kotlin, PHP and C#.
Also, all the features are based on immutability.
(Maybe other languages will be integrated, only the future will tell it)
This project has only the JavaScript / TypeScript version uploaded.
But other languages will have different features based on how they can handle it.
Language
Published
Javascript Typescript
Java
Maven
Kotlin
Maven
PHP
Composer
C#
Nuget
Here is a list of the related projects made by me
You can contribute to my projects in 2 different ways
Equivalence depending on the language
Every method used in the project has a reference in one or another language.
They are used differently across different languages.
But they should result in the same thing in the end.
They are meant to give a preview, but not always the most efficient.
The structure can sometime have an equivalent on other languages:
Quick note: For the C#, no external library other than the .NET is used (even though MoreLINQ is a fantastic library) .
Another note: Some parts may be incomplete due to some research that has to be made.
The methods directly associated to a size
size|length|count()
isEmpty()
isNotEmpty()
get size() get length() get count()
get isEmpty()
get isNotEmpty()
The methods are made to find an element or giving a value
get|at|elementAt(index)
getFirst|first()
getLast|last()
getOrElse|atOrElse|elementAtOrElse(index, defaultValue)
getOrDefault|atOrDefault|elementAtOrDefault(index)
getOrNull|atOrNull|elementAtOrNull(index)
getFirstOrDefault|firstOrDefault()
getFirstOrNull|firstOrNull()
getLastOrDefault|lastOrDefault()
getLastOrNull|lastOrNull()
findFirst|find|first(predicate)
findFirstOrNull|findOrNull|firstOrNull(predicate)
findFirstIndexed|findIndexed|firstIndexed(predicate)
findFirstIndexedOrNull|findIndexedOrNull|firstIndexedOrNull(predicate)
findLast|last(predicate)
findLastOrNull|lastOrNull(predicate)
findLastIndexed|lastIndexed(predicate)
findLastIndexedOrNull|lastIndexedOrNull(predicate)
get(index)
Language
Equivalent
Javascript
Java
Kotlin
PHP
$array[$index]
C#
getFirst()
Language
Equivalent
Javascript
0 in array ? array[0] : throw
Java
collection.stream().findFirst().orElseThrow()
Kotlin
PHP
C#
getLast()
Language
Equivalent
Javascript
size - 1 in array[size - 1] : throw
Java
collection.stream().reduce((_, it) -> it).orElseThrow()
Kotlin
PHP
C#
getOrElse(index, defaultValue)
Language
Equivalent
Javascript
index in array ? array[index] : defaultValue()
Java
index < size ? array[index] : defaultValue()
Kotlin
PHP
array_key_exists($index, $array) ? $array[$index] : defaultValue()
C#
enumerable.ElementAtOrDefault(index) ?? defaultValue()
getOrDefault(index)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
getFirstOrDefault()
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
getLastOrDefault()
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
getOrNull(index)
Language
Equivalent
Javascript
index in array ? array[index] : null
Java
index <= size ? array[index] : null
Kotlin
PHP
$array?[$index]
C#
enumerable.ElementAtOrDefault(index) ?? null
getFirstOrNull()
Language
Equivalent
Javascript
0 in array ? array[0] : null
Java
collection.stream().findFirst().orElse(null)
Kotlin
PHP
C#
getLastOrNull()
Language
Equivalent
Javascript
size - 1 in array ? array[size - 1] : null
Java
collection.stream().reduce((_, it) -> it).orElse(null)
Kotlin
PHP
C#
findFirst(predicate) findFirstIndexed(predicate)
Language
Equivalent
Javascript
array.find(predicate,) ?? throw
Java
collection.stream().filter(predicate).findFirst().orElseThrow()
Kotlin
PHP
C#
findFirstOrDefault(predicate) findFirstIndexedOrDefault(predicate)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
findFirstOrNull(predicate) findFirstIndexedOrNull(predicate)
Language
Equivalent
Javascript
Java
collection.stream().filter(predicate).findFirst().orElse(null)
Kotlin
PHP
C#
findLast(predicate) findLastIndexed(predicate)
Language
Equivalent
Javascript
array.findLast(predicate,) ?? throw
Java
collection.stream().filter(predicate).reduce((_, it) -> it).orElseThrow()
Kotlin
PHP
C#
findLastOrDefault(predicate) findLastIndexedOrDefault(predicate)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
findLastOrNull(predicate) findLastIndexedOrNull(predicate)
Language
Equivalent
Javascript
Java
collection.stream().filter(predicate).reduce((_, it) -> it).orElse(null)
Kotlin
PHP
C#
The methods are made to find an index
firstIndexOf|indexOf(element, from?, to?)
firstIndexOfOrNull|indexOfOrNull(element, from?, to?)
lastIndexOf(element, from?, to?)
lastIndexOfOrNull(element, from?, to?)
indexOfFirst|findFirstIndex|findIndex(predicate, from?, to?)
indexOfFirstOrNull|findFirstIndexOrNull|findIndexOrNull(predicate, from?, to?)
indexOfFirstIndexed|findFirstIndexIndexed|findIndexIndexed(predicate, from?, to?)
indexOfFirstIndexedOrNull|findFirstIndexIndexedOrNull|findIndexIndexedOrNull(predicate, from?, to?)
indexOfLast|findLastIndex(predicate, from?, to?)
indexOfLastOrNull|findLastIndexOrNull(predicate, from?, to?)
indexOfLastIndexed|findLastIndexIndexed(predicate, from?, to?)
indexOfLastIndexedOrNull|findLastIndexIndexedOrNull(predicate, from?, to?)
firstIndexOf(element)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
firstIndexOf(element, from)
Language Equivalent
Javascript
Java
for (var i = calculate -starting -index (from ); i < size ; i ++)
if (array [i ] == element )
return i ;
throw
Kotlin
for (i in calculate- starting- index(from).. (size - 1 ))
if (element in array[i])
return i
throw
PHP
C#
firstIndexOf(element, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
for ( let i = startingIndex ; i <= endingIndex ; i += )
if ( array [ i ] === element )
return i
throw
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
var index = startingIndex - 1 ;
while (++index <= endingIndex )
if (array [i ] == element )
return i ;
throw
Kotlin
for (i in calculate- starting- index(from).. calculate- ending- index(to))
if (element in array[i])
return i
throw
PHP
C#
foreach ( var i in calculate - starting - index ( from ) ..calculate - ending - index ( to ) )
if ( array [ i ] == element )
return i ;
throw
firstIndexOfOrNull(element)
Language Equivalent
Javascript
for ( let i = 0 ; i < size ; i ++ )
if ( array [ i ] === element )
return i
return null
Java
for (var i = 0 ; i < size ; i ++)
if (array [i ] == element )
return i ;
return null ;
Kotlin
for (i in 0 .. (size - 1 ))
if (element in array[i])
return i
return null
PHP
C#
foreach ( var i in 0 ..( size - 1 ) )
if ( array [ i ] == element )
return i ;
return null ;
firstIndexOfOrNull(element, from)
Language Equivalent
Javascript
for ( let i = calculate - starting - index ( from ) ; i < size ; i ++ )
if ( element in array [ i ] )
return i
return null
Java
for (var i = calculate -starting -index (from ); i < size ; i ++)
if (array [i ] == element )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. (size - 1 ))
if (element in array[i])
return i
return null
PHP
C#
foreach ( i in calculate - starting - index ( from ) ..( size - 1 ) )
if ( array [ i ] == element )
return i ;
return null ;
firstIndexOf(element, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
for ( let i = startingIndex ; i <= endingIndex ; i ++ )
if ( array [ i ] === element )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
for (var i = startingIndex ; i < endingIndex ; i ++)
if (array [i ] == element )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. calculate- ending- index(to))
if (element in array[i])
return i
return null
PHP
C#
foreach ( var i in calculate - starting - index ( from ) ..calculate - ending - index ( to ) )
if ( array [ i ] == element )
return i ;
return null ;
lastIndexOf(element)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
lastIndexOf(element, from)
Language Equivalent
Javascript
Java
final var startingIndex = calculate -starting -index (from );
var index = size ;
while (--index >= startingIndex )
if (array [index ] == element )
return index ;
throw
Kotlin
val startingIndex = calculate- starting- index(from)
var index = size
while (-- index >= startingIndex)
if (element in array[index])
return index
throw
PHP
C#
lastIndexOf(element, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
var index = endingIndex + 1
while ( -- index >= startingIndex )
if ( array [ index ] == element )
return index
throw
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
var index = endingIndex + 1 ;
while (--index >= startingIndex )
if (array [index ] == element )
return index ;
throw
Kotlin
val startingIndex = calculate- starting- index(from)
val endingIndex = calculate- ending- index(to)
var index = endingIndex + 1
while (-- index >= startingIndex)
if (element in array[index])
return index
throw
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var endingIndex = calculate - ending - index ( to ) ;
var index = endingIndex + 1 ;
while ( -- index >= startingIndex )
if ( array [ index ] == element )
return index ;
return null ;
lastIndexOfOrNull(element)
Language Equivalent
Javascript
for (let i = size - 1 ; i > -1 ; i --)
if (array [i ] === element )
return i
return null
Java
for (var i = size - 1 ; i > -1 ; i --)
if (array [i ] == element )
return i ;
return null ;
Kotlin
for (i in (size - 1 ) downTo 0 )
if (element in array[i])
return i
return null
PHP
C#
for ( var i = size - 1 ; i >= - 1 ; i -- )
if ( array [ i ] == element )
return i ;
return null ;
lastIndexOfOrNull(element, from)
Language Equivalent
Javascript
const startingIndex = calculate -starting -index (from )
for (let i = size - 1 ; i >= startingIndex ; i --)
if (array [i ] === element )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
for (var i = size - 1 ; i >= startingIndex ; i --)
if (array [i ] == element )
return i ;
return null ;
Kotlin
for (i in (size - 1 ) downTo calculate- starting- index(from))
if (element in array[i])
return i
return null
PHP
C#
final var startingIndex = calculate - starting - index ( from ) ;
for ( var i = size - 1 ; i >= startingIndex ; i -- )
if ( array [ i ] == element )
return i ;
return null ;
lastIndexOfOrNull(element, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
for ( let i = endingIndex ; i >= startingIndex ; i -- )
if ( array [ i ] === element )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
while (var i = endingIndex ; i >= startingIndex ; i --)
if (array [i ] == element )
return i ;
return null ;
Kotlin
val startingIndex = calculate- starting- index(from)
val endingIndex = calculate- ending- index(to)
for (i in endingIndex downTo startingIndex)
if (element in array[i])
return i
return null
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var endingIndex = calculate - ending - index ( to ) ;
while ( var i = endingIndex; i >= startingIndex; i-- )
if ( array [ i ] == element )
return i;
return null ;
indexOfFirst(predicate) indexOfFirstIndexed(predicate)
Language Equivalent
Javascript
Java
for (var i = 0 ; i < size ; i ++)
if (predicate )
return i ;
return null ;
Kotlin
PHP
C#
indexOfFirst(predicate, from) indexOfFirstIndexed(predicate, from)
Language Equivalent
Javascript
for ( let i = calculate - starting - index ( from ) ; i < size ; i ++ )
if ( predicate )
return i
return null
Java
for (var i = calculate -starting -index (from ); i < size ; i ++)
if (predicate )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. (size - 1 ))
if (predicate)
return i
return null
PHP
C#
indexOfFirst(predicate, from, to) indexOfFirstIndexed(predicate, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
for ( let i = startingIndex ; i <= endingIndex ; i ++ )
if ( predicate )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
for (var i = startingIndex ; i <= endingIndex ; i ++)
if (predicate )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. alculate- ending- index(to))
if (predicate)
return i
return null
PHP
C#
foreach ( var i in calculate - starting - index ( from ) ..calculate - ending - index ( to ) )
if ( predicate )
return i ;
return null ;
indexOfFirstOrNull(predicate) indexOfFirstIndexedOrNull(predicate)
Language Equivalent
Javascript
Java
for (let i = 0 ; i < size ; i ++)
if (predicate )
return index ;
return null ;
Kotlin
PHP
C#
indexOfFirstOrNull(predicate, from) indexOfFirstIndexedOrNull(predicate, from)
Language Equivalent
Javascript
for ( let i = calculate - starting - index ( from ) ; i < size ; i ++ )
if ( predicate )
return i
return null
Java
for (var i = calculate -starting -index (from ); i < size ; i ++)
if (predicate )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. (size - 1 ))
if (predicate)
return i
return null
PHP
C#
foreach ( var i = calculate- starting - index ( from ) ..( size - 1 ) )
if ( predicate )
return i ;
return null ;
indexOfFirstOrNull(predicate, from, to) indexOfFirstIndexedOrNull(predicate, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from )
const endingIndex = calculate - ending - index ( to )
for ( let i = startingIndex ; i < endingIndex ; i ++ )
if ( predicate )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
for (var i = startingIndex ; i < endingIndex ; i ++)
if (predicate )
return i ;
return null ;
Kotlin
for (i in calculate- starting- index(from).. calculate- ending- index(to))
if (predicate)
return i
return null
PHP
C#
foreach ( i in calculate - starting - index ( from ) ..calculate - ending - index ( to ) )
if ( predicate )
return i ;
return null ;
indexOfLast(predicate) indexOfLastIndexed(predicate)
Language Equivalent
Javascript
Java
for (var i = size - 1 ; i > -1 ; i --)
if (predicate )
return i ;
throw
Kotlin
PHP
C#
indexOfLast(predicate, from) indexOfLastIndexed(predicate, from)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
for ( let i = size - 1 ; i >= startingIndex ; i -- )
if ( predicate )
return index
throw
Java
final var startingIndex = calculate -starting -index (from );
for (var i = size - 1 ; i >= startingIndex ; i --)
if (predicate )
return index ;
throw
Kotlin
for (i in (size - 1 ) downTo calculate- starting- index(from))
if (predicate)
return index
throw
PHP
C#
indexOfLast(predicate, from, to) indexOfLastIndexed(predicate, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
const endingIndex = calculate - ending - index ( to , )
for ( let i = endingIndex ; i >= startingIndex ; i -- )
if ( predicate )
return i
throw
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
for (let i = endingIndex ; i >= startingIndex ; i --)
if (predicate )
return i ;
throw
Kotlin
val startingIndex = calculate- starting- index(from)
val endingIndex = calculate- ending- index(to)
for (i in endingIndex downTo startingIndex)
if (predicate)
return i
throw
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var endingIndex = calculate - ending - index ( to ) ;
for ( let i = endingIndex ; i >= startingIndex ; i -- )
if ( predicate )
return i ;
throw
indexOfLastOrNull(predicate) indexOfLastIndexedOrNull(predicate)
Language Equivalent
Javascript
for ( let i = size - 1 ; i > - 1 ; i -- )
if ( predicate )
return i
return null
Java
for (var i = size - 1 ; i > -1 ; i --)
if (predicate )
return i ;
return null ;
Kotlin
for (i in (size - 1 ) downTo 0 )
if (predicate)
return i;
return null ;
PHP
C#
for ( var i = size - 1 ; i > - 1 ; i -- )
if ( predicate )
return i ;
return null ;
indexOfLastOrNull(predicate, from) indexOfLastIndexedOrNull(predicate, from)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
for ( let i = size - 1 ; i >= startingIndex ; i -- )
if ( predicate )
return index
return null
Java
final var startingIndex = calculate -starting -index (from );
for (var i = size - 1 ; i >= startingIndex ; i --)
if (predicate )
return i ;
return null ;
Kotlin
val startingIndex =
var index = size
for (i in (size - 1 ) downTo calculate- starting- index(from))
if (predicate)
return i
return null
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
for ( var i = size - 1 ; i >= startingIndex ; i -- )
if ( predicate )
return i ;
return null ;
indexOfLastOrNull(predicate, from, to) indexOfLastIndexedOrNull(predicate, from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
const endingIndex = calculate - ending - index ( to , )
for ( let i = endingIndex ; i >= startingIndex ; i -- )
if ( predicate )
return i
return null
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
for (let i = endingIndex ; i >= startingIndex ; i --)
if (predicate )
return i ;
return null ;
Kotlin
val startingIndex = calculate- starting- index(from)
val endingIndex = calculate- ending- index(to)
for (i in endingIndex downTo startingIndex)
if (predicate)
return i
return null
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var endingIndex = calculate - ending - index ( to ) ;
for ( let i = endingIndex ; i >= startingIndex ; i -- )
if ( predicate )
return i ;
return null ;
The methods are made to do validation on type, value or comparison
all|every()
any|some(predicate?)
none(predicate?)
hasNull|containsNull|includesNull()
hasDuplicate|containsDuplicate|includesDuplicate()
has|contains|includes(value)
hasNot|containsNot|includesNot(value)
hasOne|containsOne|includesOne(values)
hasAll|containsAll|includesAll(values)
requireNoNulls()
all(predicate)
Language
Equivalent
Javascript
Java
collection.stream().allMatch(predicate)
Kotlin
PHP
C#
any()
Language
Equivalent
Javascript
array.length !== 0set.size !== 0
Java
array.length == 0collection.isEmpty()
Kotlin
PHP
C#
any(predicate)
Language
Equivalent
Javascript
Java
collection.stream().anyMatch(predicate)
Kotlin
PHP
C#
none()
Language
Equivalent
Javascript
array.length === 0set.size === 0
Java
array.length == 0!collection.isEmpty()
Kotlin
PHP
C#
none(predicate)
Language
Equivalent
Javascript
array.some(!predicate)
Java
collection.stream().noneMatch(predicate)
Kotlin
PHP
C#
enumerable.Any(!predicate)
hasNull()
Language
Equivalent
Javascript
array.includes(null,)
Java
collection.contains(null)
Kotlin
N/A
PHP
in_array(null, $array, true)
C#
enumerable.Contains(null)list.Contains(null)set.Contains(null)
hasDuplicate()
Language Equivalent
Javascript
const temporaryArray = new Array ( size , )
temporaryArray [ 0 ] = array [ 0 ]
let amountOfItemAdded = 1
let index = 0
while ( ++ index < size ) {
const value = array [ index ]
let index2 = - 1
while ( ++ index2 < amountOfItemAdded )
if ( temporaryArray [ index2 ] === value )
return true
temporaryArray [ amountOfItemAdded ++ ] = value
}
return false
Java
final var temporaryArray = (T []) new Object [size ]
temporaryArray [0 ] = array [0 ]
var amountOfItemAdded = 1
var index = 0
while (++index < size ) {
final var value = array [index ]
var index2 = -1
while (++index2 < amountOfItemAdded )
if (temporaryArray [index2 ] == value )
return true
temporaryArray [amountOfItemAdded ++] = value
}
return false
Kotlin
val temporaryArray = arrayOfNulls<T >(size,)
temporaryArray[0 ] = array[0 ]
var amountOfItemAdded = 1
var index = 0
while (++ index < size) {
val value = array[index]
var index2 = - 1
while (++ index2 < amountOfItemAdded)
if (temporaryArray[index2] == value)
return true
temporaryArray[amountOfItemAdded++ ] = value
}
return false
PHP
C#
var temporaryArray = new T [ size ]
temporaryArray[ 0 ] = array [ 0 ]
var amountOfItemAdded = 1
var index = 0
while ( ++ index < size ) {
var value = array [ index ]
var index2 = - 1
while ( ++ index2 < amountOfItemAdded )
if ( temporaryArray[ index2 ] == value )
return true
temporaryArray[ amountOfItemAdded ++ ] = value
}
return false
has(value)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
hasNot(value)
Language
Equivalent
Javascript
!array.includes(value)!set.has(value)
Java
Kotlin
!array.contains(value)!iterable.contains(value)
PHP
C#
hasOne(values)
Language
Equivalent
Javascript
array.some(it => values.includes(it,),)
Java
list.stream().anyMatch(values::contains)
Kotlin
array.any { it in values }
PHP
C#
enumerable.Any(it => values.Contains(it))
hasAll(values)
Language
Equivalent
Javascript
array.every(it => values.includes(it,),)
Java
Kotlin
PHP
C#
enumerable.All(it => values.Contains(it))
requireNoNulls()
Language Equivalent
Javascript
let index = - 1
while ( ++ index < size )
if ( array [ index ] == null )
throw forbidden - exception
Java
var index = -1 ;
while (++index < size )
if (array [index ] == null )
throw forbidden -exception ;
Kotlin
PHP
$ index = -1 ;
while (++$ index < $ size )
if ($ array [$ index ] == null )
throw forbidden-exception
C#
var index = - 1 ;
while ( ++ index < size )
if ( array [ index ] == null )
throw
The methods are made to transform the structure by different type or size
filter(predicate)
filterIndexed(predicate)
filterNot(predicate)
filterNotIndexed(predicate)
filterNotNull()
slice(indices)
slice(from?, to?)
take|limit(n)
takeWhile|limitWhile(predicate)
takeWhileIndexed|limitWhileIndexed(predicate)
takeLast|limitLast(n)
takeLastWhile|limitLastWhile(predicate)
takeLastWhileIndexed|limitLastWhileIndexed(predicate)
drop|skip(n)
dropWhile|skipWhile(predicate)
dropWhileIndexed|skipWhileIndexed(predicate)
dropLast|skipLast(n)
dropLastWhile|skipLastWhile(predicate)
dropLastWhileIndexed|skipLastWhileIndexed(predicate)
map(transform)
mapIndexed(transform)
mapNotNull(transform)
mapNotNullIndexed(transform)
filter(predicate)
Language
Equivalent
Javascript
Java
collection.stream().filter(predicate).toList()
Kotlin
PHP
C#
filterIndexed(predicate)
Language
Equivalent
Javascript
Java
collection.stream().filter(predicate).toList()
Kotlin
PHP
C#
filterNot(predicate) filterNotIndexed(predicate)
Language
Equivalent
Javascript
array.filter(!predicate)
Java
collection.stream().filter(!predicate).toList()
Kotlin
PHP
array_filter($array, !$predicate)
C#
enumerable.Where(!predicate)
filterNotNull()
Language
Equivalent
Javascript
array.filter(it => it != null,)
Java
collection.stream().filter(it -> it != null).toList()
Kotlin
PHP
array_filter($array, fn(it) => $array[$it] != null,)
C#
enumerable.Where(it => it != null)
slice(indices)
Language Equivalent
Javascript
const newArray = new Array ( indiceSize , )
let index = indiceSize
while ( index -- > 0 )
newArray [ index ] = array [ indices [ index ] ]
return newArray
Java
final var newArray = (T []) new Object [indiceSize ];
var index = indiceSize ;
while (index -- > 0 )
newArray [index ] = array [indices [index ]];
return newArray ;
Kotlin
PHP
C#
var newArray = new T [ indiceSize ] ;
var index = indiceSize ;
while ( index -- > 0 )
newArray [ index ] = array [ indices [ index ] ] ;
return newArray ;
slice()
Language
Equivalent
Javascript
Array.slice()
Java
array
Kotlin
array
PHP
C#
array
slice(from)
Language
Equivalent
Javascript
Array.slice(from)
Java
Arrays.copyOfRange(array, from, size - 1)
Kotlin
array[from..]array.slice(from..)
PHP
C#
array[from..^0]
slice(from, to)
Language
Equivalent
Javascript
Array.slice(from, to)
Java
Arrays.copyOfRange(array, from, to)
Kotlin
array[from..to]array.slice(from..to)
PHP
C#
array[from..to]
take(n)
Language
Equivalent
Javascript
array.slice(0, n)
Java
Kotlin
PHP
C#
takeWhile(predicate) takeWhileIndexed(predicate)
Language
Equivalent
Javascript
array.filter(predicate)
Java
Kotlin
PHP
C#
takeLast(n)
Language
Equivalent
Javascript
array.slice(-n)
Java
Kotlin
PHP
C#
takeLastWhile(predicate) takeLastWhileIndexed(predicate)
Language Equivalent
Javascript
let index = size
while ( -- index >= 0 )
if ( ! predicate ) {
const newArrayFromIndexToLast = new Array ( size - index - 1 , )
let indexAdded = 0
while ( ++ index < size )
newArrayFromIndexToLast [ indexAdded ++ ] = array [ index ]
return newArrayFromIndexToLast
}
return newArray
Java
Kotlin
PHP
C#
drop(n)
dropWhile(predicate) dropWhileIndexed(predicate)
dropLast(n)
dropLastWhile(predicate) dropLastWhileIndexed(predicate)
Language Equivalent
Javascript
let index = size
while ( -- index >= 0 )
if ( ! predicate ) {
const newArrayFrom0ToIndex = new Array ( index + 1 , )
let index2 = - 1
while ( ++ index2 <= index )
newArrayFrom0ToIndex [ index2 ] = array [ index2 ]
return newArrayFrom0ToIndex
}
return [ ]
Java
Kotlin
PHP
C#
map(transform)
Language
Equivalent
Javascript
Java
collection.stream().map(transform).toList()
Kotlin
PHP
C#
mapIndexed(transform)
Language
Equivalent
Javascript
Java
collection.stream().map(transform).toList()
Kotlin
PHP
C#
mapNotNull(transform)
Language
Equivalent
Javascript
array.map(it => it != null,)
Java
collection.stream().map(it -> it != null).toList()
Kotlin
PHP
array_map(fn(it,) => it != null, $array)
C#
enumerable.Select(it it != null)
mapNotNullIndexed(transform)
Language
Equivalent
Javascript
array.map(it => it != null,)
Java
collection.stream().map(it -> it != null).toList()
Kotlin
PHP
array_map(fn(it,) => it != null, $array)
C#
enumerable.Select(it it != null)
The methods are basically an embedded loop
forEach(action)
forEachIndexed(action)
onEach(action)
onEachIndexed(action)
forEach(action)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
forEachIndexed(action)
Language
Equivalent
Javascript
Java
Kotlin
PHP
C#
onEach(action)
Language
Equivalent
Javascript
array.forEach(action,) return array
Java
array.forEach(action); return array;
Kotlin
PHP
array_walk(&$array, $action,) return $array;
C#
list.forEach(action); return list;
onEachIndexed(action)
Language
Equivalent
Javascript
array.forEach(action,) return array
Java
array.forEach(action); return array;
Kotlin
PHP
array_walk(&$array, $action,) return $array;
C#
list.forEach(action); return list;
The methods are there to reorder the values
toReverse|toReversed|reversed(from?, to?)
toReverse()
Language
Equivalent
Javascript
Java
Collections.reverse(list)
Kotlin
PHP
C#
toReverse(from)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
const newArray = new Array ( size - 1 - startingIndex , )
let indexAdded = - 1
let index = size
while ( -- index >= startingIndex )
newArray [ ++ indexAdded ] = collection . get ( index , )
return newArray
Java
final var startingIndex = calculate -starting -index (from );
final var newArray = (T []) new Object [size - 1 - startingIndex ];
var indexAdded = -1 ;
var index = size ;
while (--index >= startingIndex )
newArray [++indexAdded ] = array [index ];
return newArray ;
Kotlin
val startingIndex = calculate- starting- index(from,)
val newArray = arrayOfNulls<T >(size - 1 - startingIndex,)
var indexAdded = - 1
var index = size
while (-- index >= startingIndex)
newArray[++ indexAdded] = array[index]
return newArray as T []
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var newArray = new T [ size - 1 - startingIndex ] ;
var indexAdded = - 1 ;
var index = size ;
while ( -- index >= startingIndex )
newArray [ ++ indexAdded ] = array [ index ] ;
return newArray ;
toReverse(from, to)
Language Equivalent
Javascript
const startingIndex = calculate - starting - index ( from , )
const endingIndex = calculate - ending - index ( to , )
const newArray = new Array ( endingIndex - startingIndex , )
let indexAdded = - 1
let index = endingIndex + 1
while ( -- index >= startingIndex )
newArray [ ++ indexAdded ] = collection . get ( index , )
return newArray
Java
final var startingIndex = calculate -starting -index (from );
final var endingIndex = calculate -ending -index (to );
final var newArray = (T []) new Object [endingIndex - startingIndex ];
var indexAdded = -1 ;
var index = endingIndex + 1 ;
while (--index >= startingIndex )
newArray [++indexAdded ] = array [index ];
return newArray ;
Kotlin
val startingIndex = calculate- starting- index(from,)
val endingIndex = calculate- ending- index(to,)
val newArray = arrayOfNulls<T >(endingIndex - startingIndex,)
var indexAdded = - 1
var index = endingIndex + 1
while (-- index >= startingIndex)
newArray[++ indexAdded] = array[index]
return newArray as T []
PHP
C#
var startingIndex = calculate - starting - index ( from ) ;
var endingIndex = calculate - ending - index ( to ) ;
var newArray = new T [ endingIndex - startingIndex ] ;
var indexAdded = - 1 ;
var index = endingIndex + 1 ;
while ( -- index >= startingIndex )
newArray [ ++ indexAdded ] = array [ index ] ;
return newArray ;
The methods are here to convert the structure to another kind depending on the language
To iterator/enumerator
This is for the structure that can use the language looping mechanism
Language
Equivalence
Javascript
Java
Kotlin
PHP
C#
To (mutable) array
This is the most bare-bones structure
Javascript Array (toArray / toMutableArray)
Java T[] (toArray)
Kotlin Array (toArray)
PHP Array
C# T[] (toArray)
Language
Equivalence toArray
Equivalence toMutableArray
Javascript
Object.freeze([...iterable,],)
[...iterable,]
Java
N/A
Kotlin
N/A
PHP
C#
new ReadOnlyCollection<T>(enumerable)
To (mutable) collection
Language
Equivalent toCollection
Equivalent toMutableCollection
Javascript
Java
Kotlin
mutableArrayOf(*iterable)mutableSetOf(*iterable)
PHP
C#
new ReadOnlyCollection<T>(enumerable)
enumerable.toList()enumerable.toHashSet()
To (mutable) list
Language
Equivalent toList
Equivalent toMutableList
Javascript
Java
new ArrayList<>(collection)new CopyOnWriteArrayList<>(collection)new LinkedList<>(collection)new Vector<>(collection)
Kotlin
PHP
C#
new ReadOnlyCollection<T>(enumerable)
To (mutable) set
Language
Equivalent toSet
Equivalent toMutableSet
Javascript
Object.freeze(new Set(iterable,),)Object.freeze(new WeakSet(iterable,),)
new Set(iterable,)new WeakSet(iterable,)
Java
new ConcurrentSkipListSet<>(collection)new CopyOnWriteArraySet<>(collection)new HashSet<>(collection)new LinkedHashSet<>(collection)new TreeSet<>(collection)
Kotlin
PHP
C#
new ReadOnlyCollection<T>(enumerable)
To (mutable) map/dictionary
Language
Equivalent toMap
Equivalent toMutableMap
Javascript
Object.freeze(new Map(array.map((it, index,) => [it, index,],),),)
new Map(array.map((it, index,) => [it, index,],),)
Java
list.stream().collect(Collectors.toUnmodifiableMap(list::indexOf, it -> it))
list.stream().collect(Collectors.toMap(list::indexOf, it -> it))
Kotlin
iterable.mapIndexed { index, i -> index to i }.toMap()
iterable.mapIndexed { index, i -> index to i }.toMap().toMutableMap()
PHP
C#
new ReadOnlyCollection<T>(enumerable)
joinToString()
Language
Equivalent
Javascript
`[${array.join(", ",)}]`
Java
array.join(", ")
Kotlin
Array.joinToString() Iterable.joinToString()
PHP
C#
'[' + string.Join(", ", array, 0, size - 1) + ']''[' + Join(", ", enumerable) + ']'
joinToString(separator)
joinToString(separator, prefix)
joinToString(separator, prefix, postfix)
joinToString(separator, prefix, postfix, limit, truncated)
joinToString(separator, prefix, postfix, limit, truncated, transform)
Language
Equivalent
Javascript
Java
Kotlin
Array.joinToString(separator, prefix, postfix, limit, truncated, transform) Iterable.joinToString(separator, prefix, postfix, limit, truncated, transform)
PHP
C#
JS/TS
Date
Quick note
1.14.0
Febuary 24th, 2026
2026 update, Handling of Nullable for hasOne, hasNotOne, hasAll, hasNotAll Removal of get collection in CollectionIteratorlazy (1.7.1 → 1.7.2), type (1.2.1 → 1.2.2)
1.13.0
August 12th, 2025
Shortening of the arguments fromIndex → from & toIndex → to New method getFirstOrElse, getLastOrElse, hasNot, hasNotAll, hasNotOne, hasNoNulls, hasNoDuplicates, Handling of Iterator in the process of the frameworklazy (1.7.0 → 1.7.1), type (1.2.0 → 1.2.1)
1.12.0
January 8th, 2025
2025 update, New methods for the Map and WeakMap,lazy (1.6.0 → 1.7.0 ), type (1.1.0 → 1.2.0 )
1.11.3
December 12th, 2024
Fix on the indexOfFirst having NullOrNumber instead of number in its return type
1.11.2
November 19th, 2024
Fix on the indexOfFirst and indexOfLast having NullOrNumber instead of number in its return type
1.11.1
November 7th, 2024
Fix on the EMPTY_MAP, EMPTY_WEAK_MAP and EMPTY_WEAK_SET in CollectionConstants to be applicable to anything
1.11.0
November 7th, 2024
New methods firstIndexOfOrNull, lastIndexOfOrNull, indexOfFirstOrNull, indexOfLastOrNull, isTypedArray (plus the specific type ), Separation of first, last into findFirst, findLast, Addition of aliases limit, skip, Re-addition of the methods (now as alias ) findIndex, findLastIndex, New methods for the aliased methods in CollectionHolderlazy (1.5.0 → 1.6.0 ), type (1.0.0 → 1.1.0 )
1.10.0
October 8th, 2024
New methods take, takeWhile, takeLast, takeLastWhile, drop, dropWhile, dropLast and dropLastWhile, New aliases some and every, Deprecation of the argument limit where there is a fromIndex and toIndex, Addition of Array to be handled in the methods
1.9.3
August 15th, 2024
Fix on the missing export for filterNotIndexed
1.9.2
July 23rd, 2024
Fix on an array of 2 on MinimalistCollectionHolder, Fix on the CollectionIterator to handle properly when it has 2 values
1.9.1
July 21st, 2024
Spread of the deprecation across the inheritor of CollectionHolder
1.9.0
July 21st, 2024
Addition of hasDuplicate, joinToString for the CollectionHolder, Change on the CollectionIterator to use NullableNumber instead of number for the indexes, Addition of implementation for the ValueHolder, Deprecation of variadic parameters for has, hasAll & hasOne, The abstract implementations no longer have fields held,lazy (1.4.0 → 1.5.0 )
1.8.0
March 31st, 2024
Addition of type to the dependency
1.7.1
February 19th, 2024
Change from == to === on the GenericCollectionIterator
1.7.0
February 19th, 2024
2024 update, New implementation of MinimalistCollectionHolder , New method has, New aliases contains, includes, reversed, toReversed, New names to the CollectionHandlers,lazy (1.2.1 → 1.3.0 )
1.6.1
December 23rd, 2023
Addition of the missing amd (asynchronous module definition) package
1.6.0
December 4th, 2023
New implementation based on the amount of arguments received in a callback, New method variant of toString, Deprecation (for removal) of the newInstance
1.5.0
September 28th, 2023
The RangeError and ReferenceError has been changed to custom exceptions,lazy (1.1.0 → 1.2.0 )
1.4.0
September 8th, 2023
Addition of a limit on every methods where it has fromIndex and toIndex, Change on the toIndex to be inclusive instead of exclusive, New methods mapNotNull, mapNotNullIndexed and slice, New aliases elementAt, elementAtOrNull and elementAtOrElse
1.3.0
August 14th, 2023
Small changes on some utility methods, Addition of nextValue and previousValue to the CollectionIterator
1.2.0
July 27th, 2023
Fix on a "for‥of" not working properly
1.1.0
July 23rd, 2023
Addition of a new CollectionIterator
1.0.4
July 2nd, 2023
There were recursive import for the EmptyCollectionHolder from the CollectionConstants
1.0.3
July 1st, 2023
For some reason, the file CollectionHolder had a Symbol not declared
1.0.2
July 1st, 2023
Small fix on the package.json
1.0.1
July 1st, 2023
An update based on the new lazy version
1.0.0
July 1st, 2023
The first version, It was originally on the enumeration project