NX01: Rename to numeric modules and split collections2
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 49s

This commit is contained in:
Willem Cazander 2026-02-02 18:46:48 +01:00
parent c67142faba
commit b8855069df
77 changed files with 191 additions and 118 deletions

View file

@ -0,0 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.nx01</groupId>
<artifactId>nx01</artifactId>
<version>5786.SHEVAT〄.1-SNAPSHOT</version>
</parent>
<artifactId>nx01-jpp0-collections2</artifactId>
<dependencies>
<dependency>
<groupId>love.distributedrebirth.nx01</groupId>
<artifactId>nx01-jpp0-land</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,37 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/// The nx01 jpp0 collections2 module.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
module ᣕᕁᐤᣳ.ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ {
requires transitive ᣕᕁᐤᣳ.ᒢᣘᐧᐧ.ᒻᣔᣕᒄ;
exports ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
exports ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ;
exports ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ;
}

View file

@ -0,0 +1,50 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.Rope;
/// Appender
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface AppenderOpen<E> {
boolean add(E obj);
default boolean addAll(Yarn<? extends E> yarn) {
boolean result = false;
Rope<? extends E> iterator = yarn.rope();
while (iterator.hasNext()) {
if (add(iterator.next())) {
result = true;
}
}
return result;
}
}

View file

@ -0,0 +1,251 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.Rope;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeIterable;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeLadder;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeLadderOpen;
/// Array ladder
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class ArrayLadderOpen<E> implements LadderOpen<E>,RopeIterable<E> {
// TODO: Rewrite to Arena based array
private final List<E> data;
public ArrayLadderOpen() {
this(new ArrayList<>());
}
public ArrayLadderOpen(List<E> data) {
if (data == null) {
throw new NullPointerException("Can't create list with null data");
}
this.data = data;
}
@Deprecated // limited to int
public ArrayLadderOpen(E[] data) {
if (data == null) {
throw new NullPointerException("Can't create list with null data");
}
this.data = Arrays.asList(data);
}
// ---- Listᵂʳ
@Override
public Rope<E> rope() {
return Rope.wrapᴼᶠ(data.iterator());
}
@Override
public boolean add(E value) {
return data.add(value);
}
@Override
public boolean remove(Object o) {
return data.remove(o);
}
@Override
public void add(long index, E element) {
data.add((int) index, element);
}
@Override
public E remove(long index) {
return data.remove((int) index);
}
@Override
public E set(long index, E element) {
return data.set((int) index, element);
}
@Override
public void sort(Comparator<? super E> c) { // TODO: add default impl
data.sort(c);
}
// ---- Optional, but for speed
@Override
public void forEach(Consumer<? super E> action) {
data.forEach(action);
}
@Override
public void clear() {
data.clear();
}
@Override
public boolean removeAll(Yarn<?> set) {
return data.removeAll(set.toCollection());
}
@Override
public boolean removeIf(Predicate<? super E> filter) {
return data.removeIf(filter);
}
@Override
public boolean retainAll(Yarn<?> set) {
return data.retainAll(set.toCollection());
}
@Override
public E get(long index) {
return data.get((int) index);
}
@Override
public int indexOf(Object o) {
return data.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return data.lastIndexOf(o);
}
@Override
public RopeLadder<E> ropeLadder() {
return RopeLadder.wrapᴼᶠ(data.listIterator());
}
@Override
public RopeLadder<E> ropeLadder(long index) {
return RopeLadder.wrapᴼᶠ(data.listIterator((int) index));
}
@Override
public Ladder<E> subLadder(long fromIndex, long toIndex) {
return new ArrayLadderOpen<>(data.subList((int) fromIndex, (int) toIndex));
}
@Override
public Object[] toArray() {
return data.toArray();
}
@Override
public <T> T[] toArray(T[] arr) {
return data.toArray(arr);
}
@Override
public long size() {
return data.size();
}
@Override
public boolean isEmpty() {
return data.isEmpty();
}
@Override
public boolean contains(Object obj) {
return data.contains(obj);
}
@Override
public boolean containsAll(Yarn<?> set) {
return data.containsAll(set.toCollection());
}
@Override
public Stream<E> parallelStream() {
return data.parallelStream();
}
@Override
public Spliterator<E> spliterator() {
return data.spliterator();
}
@Override
public Stream<E> stream() {
return data.stream();
}
@Override
public boolean addAll(Yarn<? extends E> c) {
return data.addAll(c.toCollection());
}
// @Override
// public void forEach(Consumer<? super E> action) {
// data.forEach(action);
// }
//
// @Override
// public Spliterator<E> spliterator() {
// return data.spliterator();
// }
@Override
public boolean addAll(long index, Yarn<? extends E> c) {
return data.addAll((int) index, c.toCollection());
}
@Override
public void replaceAll(UnaryOperator<E> operator) {
data.replaceAll(operator);
}
@Override
public RopeLadderOpen<E> ropeLadderOpen() {
return RopeLadderOpen.wrapᴼᶠ(data.listIterator());
}
@Override
public RopeLadderOpen<E> ropeLadderOpen(long index) {
return RopeLadderOpen.wrapᴼᶠ(data.listIterator((int) index));
}
@Override
public LadderOpen<E> subLadderOpen(long fromIndex, long toIndex) {
return new ArrayLadderOpen<>(data.subList((int) fromIndex, (int) toIndex));
}
}

View file

@ -0,0 +1,88 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import java.util.stream.Collectors;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ.Zerdinal;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeLadder;
/// Ladder
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface Ladder<E> extends Yarn<E> {
default E get(Zerdinal index) {
return get(index.zerdinal());
}
default E get(long index) {
return stream().skip(index).collect(Collectors.toList()).get(0);
}
default int indexOf(Object o) {
return stream().collect(Collectors.toList()).indexOf(o);
}
default int lastIndexOf(Object o) {
return stream().collect(Collectors.toList()).lastIndexOf(o);
}
default RopeLadder<E> ropeLadder() {
return ropeLadder(0);
}
default RopeLadder<E> ropeLadder(Zerdinal index) {
return ropeLadder(index.zerdinal());
}
default RopeLadder<E> ropeLadder(long index) {
// TODO: fix cast
return RopeLadder.wrapᴼᶠ(stream().collect(Collectors.toList()).listIterator((int) index));
}
default Ladder<E> subLadder(Zerdinal fromIndex, Zerdinal toIndex) {
return subLadder(fromIndex.zerdinal(), toIndex.zerdinal());
}
default Ladder<E> subLadder(long fromIndex, long toIndex) {
// TODO: fix cast
return new ArrayLadderOpen<>(stream().collect(Collectors.toList()).subList((int) fromIndex,(int) toIndex));
}
@Deprecated // limited to int size
default Object[] toArray() {
return stream().collect(Collectors.toList()).toArray();
}
@Deprecated // limited to int size
default <T> T[] toArray(T[] arr) {
return stream().collect(Collectors.toList()).toArray(arr);
}
}

View file

@ -0,0 +1,104 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import java.util.Comparator;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ.Zerdinal;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.Rope;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeLadderOpen;
/// Ladder open
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface LadderOpen<E> extends Ladder<E>, YarnOpen<E> {
default void add(Zerdinal index, E element) {
add(index.zerdinal(), element);
}
void add(long index, E element);
default boolean addAll(Zerdinal index, Yarn<? extends E> c) {
return addAll(index.zerdinal(), c);
}
default boolean addAll(long index, Yarn<? extends E> c) {
Rope<? extends E> iterator = c.rope();
boolean result = iterator.hasNext();
while (iterator.hasNext()) {
add(index, iterator.next());
}
return result;
}
default E remove(Zerdinal index) {
return remove(index.zerdinal());
}
E remove(long index);
default void replaceAll(UnaryOperator<E> operator) {
for (int i = 0; i < size(); i++) {
set(i, operator.apply(get(i)));
}
}
default E set(Zerdinal index, E element) {
return set(index.zerdinal(), element);
}
E set(long index, E element);
/* default */ void sort(Comparator<? super E> c);
default RopeLadderOpen<E> ropeLadderOpen() {
return ropeLadderOpen();
}
default RopeLadderOpen<E> ropeLadderOpen(Zerdinal index) {
return ropeLadderOpen(index.zerdinal());
}
default RopeLadderOpen<E> ropeLadderOpen(long index) {
// TODO: fix cast
return RopeLadderOpen.wrapᴼᶠ(stream().collect(Collectors.toList()).listIterator((int) index));
}
default LadderOpen<E> subLadderOpen(Zerdinal fromIndex, Zerdinal toIndex) {
return subLadderOpen(fromIndex.zerdinal(), toIndex.zerdinal());
}
default LadderOpen<E> subLadderOpen(long fromIndex, long toIndex) {
// TODO: fix cast
return new ArrayLadderOpen<>(stream().collect(Collectors.toList()).subList((int) fromIndex, (int) toIndex));
}
}

View file

@ -0,0 +1,87 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import java.util.Collection;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.RopeIterable;
/// A sized rope is a collection on a yarn.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface Yarn<E> extends RopeIterable<E> {
default long size() {
return stream().count();
}
default boolean isEmpty() {
return rope().hasNext() == false;
}
default boolean contains(Object obj) {
return stream().collect(Collectors.toSet()).contains(obj);
}
default boolean containsAll(Yarn<?> set) {
return stream().collect(Collectors.toSet()).containsAll(set.stream().collect(Collectors.toSet()));
}
default Stream<E> parallelStream() {
return stream().parallel();
}
default Spliterator<E> spliterator() {
return Spliterators.spliteratorUnknownSize(rope().toIterator(), Spliterator.ORDERED);
}
@Deprecated // limited to int size
default Object[] toArray() {
return stream().collect(Collectors.toList()).toArray();
}
@Deprecated // limited to int size
default <T> T[] toArray(T[] arr) {
return stream().collect(Collectors.toList()).toArray(arr);
}
default Stream<E> stream() {
return StreamSupport.stream(spliterator(), false);
}
// TODO; add interface wrappers
default Collection<E> toCollection() {
return stream().collect(Collectors.toList());
}
}

View file

@ -0,0 +1,173 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ;
import java.util.Collection;
import java.util.Iterator;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.Rope;
/// A open yarn.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface YarnOpen<E> extends Yarn<E>, AppenderOpen<E> {
boolean remove(Object obj);
default void clear() {
stream().collect(Collectors.toList()).forEach(v -> remove(v));
}
default boolean removeAll(Yarn<?> yarn) {
boolean result = false;
Rope<?> iterator = yarn.rope();
while (iterator.hasNext()) {
if (remove(iterator.next())) {
result = true;
}
}
return result;
}
default boolean removeIf(Predicate<? super E> filter) {
return removeAll(new ArrayLadderOpen<>(this.stream().filter(filter).toList()));
}
default boolean retainAll(Yarn<?> yarn) {
boolean result = false;
for (E e:stream().collect(Collectors.toList())) {
if (!yarn.contains(e)) {
remove(e);
result = true;
}
}
return result;
}
default Collection<E> toCollectionOpen() {
return wrapᴼᶠ(this);
}
static <T> YarnOpen<T> wrapᴼᶠ(Collection<T> collection) {
Objects.requireNonNull(collection);
return new YarnOpen<>() {
@Override
public Rope<T> rope() {
return Rope.wrapᴼᶠ(collection.iterator());
}
@Override
public boolean add(T obj) {
return collection.add(obj);
}
@Override
public boolean remove(Object obj) {
return collection.remove(obj);
}
};
}
static <T> Collection<T> wrapᴼᶠ(YarnOpen<T> yarn) {
Objects.requireNonNull(yarn);
return new Collection<>() {
@Override
public int size() {
return (int) yarn.size();
}
@Override
public boolean isEmpty() {
return yarn.isEmpty();
}
@Override
public boolean contains(Object obj) {
return yarn.contains(obj);
}
@Override
public Iterator<T> iterator() {
return yarn.rope().toIterator();
}
@Override
public Object[] toArray() {
return yarn.toArray();
}
@Override
public <T> T[] toArray(T[] arr) {
return yarn.toArray(arr);
}
@Override
public boolean add(T obj) {
return yarn.add(obj);
}
@Override
public boolean remove(Object obj) {
return yarn.remove(obj);
}
@Override
public boolean containsAll(Collection<?> collection) {
return yarn.containsAll(YarnOpen.wrapᴼᶠ(collection));
}
@Override
public boolean addAll(Collection<? extends T> collection) {
return yarn.addAll(YarnOpen.wrapᴼᶠ(collection));
}
@Override
public boolean removeAll(Collection<?> collection) {
return yarn.removeAll(YarnOpen.wrapᴼᶠ(collection));
}
@Override
public boolean retainAll(Collection<?> collection) {
return yarn.retainAll(YarnOpen.wrapᴼᶠ(collection));
}
@Override
public void clear() {
yarn.clear();
}
};
}
}

View file

@ -0,0 +1,38 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ;
/// Zerdinal numbering schema is the place where zero is one.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface Zerdinal {
/// Unsigned long for positive zero based index pointer.
long zerdinal();
}

View file

@ -0,0 +1,38 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ;
/// Provides a space boundery for zerdinal numbers.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface ZerdinalSpaceBoundary extends Zerdinal {
/// The cardinal capacity of this bounded zerdinal number space.
long zerdinalSpaceBoundary();
}

View file

@ -0,0 +1,90 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import ᒢᣘᐧᐧ.ᒻᣔᣕᒄ.LandTBone;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ArrayLadderOpen;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.Ladder;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.LadderOpen;
import ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ.Rope;
/// Materialize a zerdinal number object from space.
///
/// @param <T> The self type used by the creator.
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface ZerdinalSpaceMaterializer<T extends ZerdinalSpaceMaterializer<T>> extends ZerdinalSpaceBoundary, LandTBone<T> {
/// Materialize an number from the bounded zerdinal number space.
T zerdinalMaterializeSpace(long zerdinal);
default Rope<T> zerdinalSpaceRope() {
return new Rope<T>() {
int zerdinalSpaceWalker = 0;
@Override
public boolean hasNext() {
return zerdinalSpaceWalker < zerdinalSpaceBoundary();
}
@Override
public T next() {
if (zerdinalSpaceWalker >= zerdinalSpaceBoundary()) {
throw new NoSuchElementException("Rope roll out does not extend past the zerdinal space boundry: " + zerdinalSpaceBoundary());
}
T result = zerdinalMaterializeSpace(zerdinalSpaceWalker);
zerdinalSpaceWalker++;
return result;
}
};
}
default void zerdinalSpaceRopeWalk(Consumer<T> consumer) {
zerdinalSpaceRope().forEachRemaining(consumer);
}
default <X> Ladder<X> zerdinalSpaceRodsToLadder(Function<T, X> mapper) {
LadderOpen<X> result = new ArrayLadderOpen<>();
zerdinalSpaceRopeWalk(v -> result.add(mapper.apply(v)));
return result;
}
default Ladder<T> zerdinalSpaceRodsToLadder() {
return zerdinalSpaceRodsToLadder(v -> v);
}
default Map<String, T> zerdinalSpaceRodsToMap(Function<T, String> keyMapper) {
return zerdinalSpaceRodsToLadder().stream().collect(Collectors.toMap(keyMapper, v -> v));
}
}

View file

@ -0,0 +1,34 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* NX01 J++ collections2 zerdinal space division.
*
*
* @since 1.0
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᙆᓫᣗᒄᑊᣕᣔᒻ;

View file

@ -0,0 +1,82 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ;
import java.util.Iterator;
import java.util.function.Consumer;
/// Read Only Programmable Enumeration.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface Rope<E> {
boolean hasNext();
E next();
default Iterator<E> toIterator() {
return wrapᴼᶠ(this);
}
default void forEachRemaining(Consumer<? super E> action) {
while (hasNext()) {
action.accept(next());
}
}
static <T> Iterator<T> wrapᴼᶠ(Rope<T> iterator) {
return new Iterator<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
};
}
static <T> Rope<T> wrapᴼᶠ(Iterator<T> iterator) {
return new Rope<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
};
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.StreamSupport;
/// Make an object iterable with a rope.
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
/// @param <E> The value of the robe parts.
public interface RopeIterable<E> {
Rope<E> rope();
default void forEach(Consumer<? super E> action) {
rope().forEachRemaining(action);
}
default Spliterator<E> spliterator() {
return Spliterators.spliteratorUnknownSize(rope().toIterator(), Spliterator.ORDERED);
}
default <A, R> R collect(Collector<? super E, A, R> collector) {
return StreamSupport.stream(spliterator(), false).collect(collector);
}
default Iterable<E> toIterable() {
return new Iterable<>() {
@Override
public Iterator<E> iterator() {
return rope().toIterator();
}
};
}
}

View file

@ -0,0 +1,74 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ;
import java.util.ListIterator;
/// Rope ladder
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface RopeLadder<E> extends Rope<E> {
boolean hasPrevious();
long nextIndex();
E previous();
long previousIndex();
static <T> RopeLadder<T> wrapᴼᶠ(ListIterator<T> iterator) {
return new RopeLadder<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
@Override
public boolean hasPrevious() {
return iterator.hasPrevious();
}
@Override
public long nextIndex() {
return iterator.nextIndex();
}
@Override
public T previous() {
return iterator.previous();
}
@Override
public long previousIndex() {
return iterator.previousIndex();
}
};
}
}

View file

@ -0,0 +1,130 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ᒢᣘᐧᐧ.ᒼᐤᒻᒻᓫᒼᐪᑊᐤᣕᔆᒾ.ᣗᐤᣖᓫ;
import java.util.ListIterator;
/// Rope ladder open
///
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public interface RopeLadderOpen<E> extends RopeLadder<E>, Rope<E> {
void remove();
void add(E obj);
void set(E obj);
default ListIterator<E> toListIterator() {
return wrapᴼᶠ(this);
}
@Deprecated // limited to int
static <T> ListIterator<T> wrapᴼᶠ(RopeLadderOpen<T> iterator) {
return new ListIterator<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
@Override
public void add(T obj) {
iterator.add(obj);
}
@Override
public boolean hasPrevious() {
return iterator.hasPrevious();
}
@Override
public int nextIndex() {
return (int) iterator.nextIndex();
}
@Override
public T previous() {
return iterator.previous();
}
@Override
public int previousIndex() {
return (int) iterator.previousIndex();
}
@Override
public void remove() {
iterator.remove();
}
@Override
public void set(T obj) {
iterator.set(obj);
}
};
}
static <T> RopeLadderOpen<T> wrapᴼᶠ(ListIterator<T> iterator) {
return new RopeLadderOpen<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
@Override
public boolean hasPrevious() {
return iterator.hasPrevious();
}
@Override
public long nextIndex() {
return iterator.nextIndex();
}
@Override
public T previous() {
return iterator.previous();
}
@Override
public long previousIndex() {
return iterator.previousIndex();
}
@Override
public void add(T obj) {
iterator.add(obj);
}
@Override
public void set(T obj) {
iterator.set(obj);
}
@Override
public void remove() {
iterator.remove();
}
};
}
}