From bb0c0c937ae728cdeef2cc2870034c85fcfc77f9 Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 24 Oct 2022 16:49:37 +0200 Subject: [PATCH] Added full wrap of List --- .../apps/DemoNumberMatrixDeskApp.java | 2 +- .../boot/desktop/GDXAppDesktopLauncher.java | 2 +- .../bassboon/jpp/util/ArrayListᴿᵂ.java | 153 +++++++++++++++++- .../bassboon/jpp/util/Collectionᴿᵈ.java | 10 ++ .../bassboon/jpp/util/Collectionᵂʳ.java | 6 +- .../bassboon/jpp/util/Iterableᴿᵈ.java | 2 +- .../numberxd/x4o/NumberXDModuleLoader.java | 2 +- 7 files changed, 169 insertions(+), 8 deletions(-) diff --git a/gdxapp4d-app-glyphdemo/src/main/java/love/distributedrebirth/gdxapp4d/app/glyphdemo/apps/DemoNumberMatrixDeskApp.java b/gdxapp4d-app-glyphdemo/src/main/java/love/distributedrebirth/gdxapp4d/app/glyphdemo/apps/DemoNumberMatrixDeskApp.java index d62d2577..f0d00071 100644 --- a/gdxapp4d-app-glyphdemo/src/main/java/love/distributedrebirth/gdxapp4d/app/glyphdemo/apps/DemoNumberMatrixDeskApp.java +++ b/gdxapp4d-app-glyphdemo/src/main/java/love/distributedrebirth/gdxapp4d/app/glyphdemo/apps/DemoNumberMatrixDeskApp.java @@ -59,7 +59,7 @@ public class DemoNumberMatrixDeskApp extends AbstractDeskApp implements DeskAppR } ImGui.tableHeadersRow(); - for (BãßBȍőnNumberMatrixʸᴰ part:numberMatrix.waardes().iterable()) { + for (BãßBȍőnNumberMatrixʸᴰ part:numberMatrix.waardes().iterableᴼᶠ()) { ImGui.tableNextRow(); ImGui.tableNextColumn(); diff --git a/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopLauncher.java b/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopLauncher.java index e8ac181d..676f454e 100644 --- a/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopLauncher.java +++ b/gdxapp4d-boot-desktop/src/main/java/love/distributedrebirth/gdxapp4d/boot/desktop/GDXAppDesktopLauncher.java @@ -22,7 +22,7 @@ public class GDXAppDesktopLauncher { GDXAppDesktopConfig.printBootMessage(); List args = Arrays.asList(arg); if (args.contains(GDXAppDesktopConfig.SINGLE_THREAD_JVM)) { - GDXAppDesktopConfig.LOG.info("Bãß.характеристики.cpu=SINGLE_THREAD_JVM)"); + GDXAppDesktopConfig.LOG.info("Bãß.характеристики.cpu=SINGLE_THREAD_JVM"); Bãß.характеристики.熱蘭遮城.ױזךיךזװןיןיןןזױז(); } diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java index b8d49525..7d1ac14d 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/ArrayListᴿᵂ.java @@ -4,6 +4,11 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; 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 love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; @@ -23,11 +28,15 @@ public class ArrayListᴿᵂ implements Listᵂʳ,Iterable { this.data = data; } + // ---- Iterable + @Override public Iterator iterator() { return data.iterator(); } + // ---- Listᵂʳ + @Override public Iteratorᴿᵈ iteratorᴿᵈ() { return Iteratorᴿᵈ.wrapᴼᶠ(iterator()); @@ -64,7 +73,149 @@ public class ArrayListᴿᵂ implements Listᵂʳ,Iterable { } @Override - public void sortᵂʳ(Comparator c) { + public void sortᵂʳ(Comparator c) { // TODO: add default impl data.sort(c); } + + // ---- Optional, but for speed + + @Override + public void forEachᴿᵈ(Consumer action) { + data.forEach(action); + } + + @Override + public void clearᵂʳ() { + data.clear(); + } + + @Override + public boolean removeAllᵂʳ(Collectionᴿᵈ set) { + return data.removeAll(set.collectionᴼᶠ()); + } + + @Override + public boolean removeIfᵂʳ(Predicate filter) { + return data.removeIf(filter); + } + + @Override + public boolean retainAllᵂʳ(Collectionᴿᵈ set) { + return data.retainAll(set.collectionᴼᶠ()); + } + + @Override + public E getᴿᵈ(int index) { + return data.get(index); + } + + @Override + public int indexOfᴿᵈ(Object o) { + return data.indexOf(o); + } + + @Override + public int lastIndexOfᴿᵈ(Object o) { + return data.lastIndexOf(o); + } + + @Override + public ListIteratorᴿᵈ listIteratorᴿᵈ() { + return ListIteratorᴿᵈ.wrapᴼᶠ(data.listIterator()); + } + + @Override + public ListIteratorᴿᵈ listIteratorᴿᵈ(int index) { + return ListIteratorᴿᵈ.wrapᴼᶠ(data.listIterator(index)); + } + + @Override + public Listᴿᵈ subListᴿᵈ(int fromIndex, int toIndex) { + return new ArrayListᴿᵂ<>(data.subList(fromIndex, toIndex)); + } + + @Override + public Object[] toArrayᴿᵈ() { + return data.toArray(); + } + + @Override + public T[] toArrayᴿᵈ(T[] arr) { + return data.toArray(arr); + } + + @Override + public int 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ᴿᵈ(Collectionᴿᵈ set) { + return data.containsAll(set.collectionᴼᶠ()); + } + + @Override + public Stream parallelStreamᴿᵈ() { + return data.parallelStream(); + } + + @Override + public Spliterator spliteratorᴿᵈ() { + return data.spliterator(); + } + + @Override + public Stream streamᴿᵈ() { + return data.stream(); + } + + @Override + public boolean addAllᵂʳ(Collectionᴿᵈ c) { + return data.addAll(c.collectionᴼᶠ()); + } + + @Override + public void forEach(Consumer action) { + data.forEach(action); + } + + @Override + public Spliterator spliterator() { + return data.spliterator(); + } + + @Override + public boolean addAllᵂʳ(int index, Collectionᴿᵈ c) { + return data.addAll(index, c.collectionᴼᶠ()); + } + + @Override + public void replaceAllᵂʳ(UnaryOperator operator) { + data.replaceAll(operator); + } + + @Override + public ListIteratorᵂʳ listIteratorᵂʳ() { + return ListIteratorᵂʳ.wrapᴼᶠ(data.listIterator()); + } + + @Override + public ListIteratorᵂʳ listIteratorᵂʳ(int index) { + return ListIteratorᵂʳ.wrapᴼᶠ(data.listIterator(index)); + } + + @Override + public Listᵂʳ subListᵂʳ(int fromIndex, int toIndex) { + return new ArrayListᴿᵂ<>(data.subList(fromIndex, toIndex)); + } } diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java index 7dc3367e..0dcccf8f 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᴿᵈ.java @@ -1,5 +1,6 @@ package love.distributedrebirth.bassboon.jpp.util; +import java.util.Collection; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Collectors; @@ -11,6 +12,11 @@ import love.distributedrebirth.bassboon.clazz.BãßBȍőnAuthor注; @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") public interface Collectionᴿᵈ extends Iterableᴿᵈ { +// default NumberValue sizeBigᴿᵈ() { +// return null; +// } +// +// @Deprecated default int sizeᴿᵈ() { return (int) streamᴿᵈ().count(); } @@ -46,4 +52,8 @@ public interface Collectionᴿᵈ extends Iterableᴿᵈ { default Stream streamᴿᵈ() { return StreamSupport.stream(spliteratorᴿᵈ(), false); } + + default Collection collectionᴼᶠ() { + return streamᴿᵈ().collect(Collectors.toList()); + } } diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java index b5a55e03..327e0d5d 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Collectionᵂʳ.java @@ -16,7 +16,7 @@ public interface Collectionᵂʳ extends Collectionᴿᵈ, Appenderᵂʳ removeᵂʳ(v)); } - default boolean removeAll(Collectionᴿᵈ set) { + default boolean removeAllᵂʳ(Collectionᴿᵈ set) { boolean result = false; Iteratorᴿᵈ iterator = set.iteratorᴿᵈ(); while (iterator.hasNextᴿᵈ()) { @@ -27,7 +27,7 @@ public interface Collectionᵂʳ extends Collectionᴿᵈ, Appenderᵂʳ filter) { + default boolean removeIfᵂʳ(Predicate filter) { boolean result = false; Iteratorᵂʳ iterator = iteratorᵂʳ(); while (iterator.hasNextᴿᵈ()) { @@ -39,7 +39,7 @@ public interface Collectionᵂʳ extends Collectionᴿᵈ, Appenderᵂʳ set) { + default boolean retainAllᵂʳ(Collectionᴿᵈ set) { boolean result = false; for (E e:streamᴿᵈ().collect(Collectors.toList())) { if (!set.containsᴿᵈ(e)) { diff --git a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java index 5e353f24..c4a64fa2 100644 --- a/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java +++ b/gdxapp4d-lib-bassboonyd/src/main/java/love/distributedrebirth/bassboon/jpp/util/Iterableᴿᵈ.java @@ -20,7 +20,7 @@ public interface Iterableᴿᵈ { return Spliterators.spliteratorUnknownSize(iteratorᴿᵈ().iteratorᴼᶠ(), Spliterator.ORDERED); } - default Iterable iterable() { + default Iterable iterableᴼᶠ() { return new Iterable<>() { @Override public Iterator iterator() { diff --git a/gdxapp4d-lib-numberxd/src/main/java/love/distributedrebirth/numberxd/x4o/NumberXDModuleLoader.java b/gdxapp4d-lib-numberxd/src/main/java/love/distributedrebirth/numberxd/x4o/NumberXDModuleLoader.java index ce9530b8..09943f35 100644 --- a/gdxapp4d-lib-numberxd/src/main/java/love/distributedrebirth/numberxd/x4o/NumberXDModuleLoader.java +++ b/gdxapp4d-lib-numberxd/src/main/java/love/distributedrebirth/numberxd/x4o/NumberXDModuleLoader.java @@ -105,7 +105,7 @@ public class NumberXDModuleLoader implements X4OLanguageModuleLoader { } private void configBãßBȍőnPartAttributes(X4OLanguage language,ElementClass ec, BãßBȍőnPartʸᴰ basePart) throws X4OLanguageModuleLoaderException { - for (BãßBȍőnPartʸᴰ part: basePart.teŀráàmWaardes().iterable()) { + for (BãßBȍőnPartʸᴰ part: basePart.teŀráàmWaardes().iterableᴼᶠ()) { ec.addElementClassAttribute(createElementClassAttribute(language,part.rȧñkChinaSleutel(),true,new BãßBȍőnPartDialToneConverter(part))); } }