andrewoma / dexx Goto Github PK
View Code? Open in Web Editor NEWPersistent (immutable) collections for Java and Kotlin
License: MIT License
Persistent (immutable) collections for Java and Kotlin
License: MIT License
It would be useful for the Dexx artifacts to include OSGi metadata, and the cost is very low. I include a PR that does the job for the Java artifact. Thanks!
val myMutableMap = mutableMap.of("key" to "value")
// val myImmutableMap = myMutableMap.toImmutableMap() -- Does not exist
The version of Dexx Collections available from Maven Central is 0.2, but it seems that there have been several moves ahead since 2014 (when that Maven Central release was made). Is it possible to please have a more recent release supplied? Thanks!
import com.github.andrewoma.dexx.collection.TreeMap;
public class Test {
public static void main(String[] args) {
TreeMap<Integer, String> map = new TreeMap<>();
map = map.put(new Integer(0), "0");
map = map.put(new Integer(50), "50");
System.out.println(map.to(new Integer(101), false).values());
}
}```
This little harmless looking piece of code generates an exception:
java.lang.RuntimeException: Defect: unexpected empty zipper while computing range
at com.github.andrewoma.dexx.collection.internal.redblack.RedBlackTree.findDepth(RedBlackTree.java:514)
at com.github.andrewoma.dexx.collection.internal.redblack.RedBlackTree.findDepth(RedBlackTree.java:517)
at com.github.andrewoma.dexx.collection.internal.redblack.RedBlackTree.rebalance(RedBlackTree.java:533)
at com.github.andrewoma.dexx.collection.internal.redblack.RedBlackTree.doUntil(RedBlackTree.java:390)
at com.github.andrewoma.dexx.collection.internal.redblack.RedBlackTree.until(RedBlackTree.java:128)
at com.github.andrewoma.dexx.collection.TreeMap.to(TreeMap.java:169)
Note that adding another pair, adding the values in a different order or querying for a key that is available prevents the exception from being thrown.
Please fix
See relevant issue ben-manes/caffeine#364
The case is it often happens that people place artifact jars to a single folder, and they use just artifact name for the file name.
If different artifacts use collection
for the artifactId
, then it would cause trouble (like with com.github.ben-manes.caffeine:guava
which happened to produce guava.jar
:-/ )
I had an object consisting of three scalar values the .equals()
method used the equals()
method on these for comparison.
The set continued to contain duplicates. Implementing hashCode()
with respect to the scalar values was the only solution.
Android has a 64k method limit, so a lot of Android developers take method count into consideration when choosing libraries.
As this library appears to be pretty compact (especially compared to some of the bloat-ridden alternatives like Guava) highlighting the method count might encourage more use by Android developers.
Is there anyway to add benchmarks of what Dexx's performance is compared to Java acting in the same way? I've been using the java.util
collections in an immutable fashion for a while, and the most telling benchmark in there for immutable use of the java collections is prepending elements to a list.
Also, a side note, it may be nice to have Sets.collector(), Lists.collector() etc to work with Java 1.8's collection streaming interface; I've done a couple of trivial ones that I might be able to make a pull request for when I finish with the project I'm currently working on (scheduled for delivery mid-to-late March).
Hello,
I noticed that sets don't support null elements.
java.lang.NullPointerException
at com.github.andrewoma.dexx.collection.internal.hashmap.CompactHashMap.put(CompactHashMap.java:69)
at com.github.andrewoma.dexx.collection.HashSet.add(HashSet.java:88)
at com.github.andrewoma.dexx.collection.HashSet.add(HashSet.java:36)
[...]
java.lang.NullPointerException
at com.github.andrewoma.dexx.collection.internal.hashmap.CompactHashMap.put(CompactHashMap.java:69)
at com.github.andrewoma.dexx.collection.HashSet.add(HashSet.java:88)
at com.github.andrewoma.dexx.collection.Sets.copyOf(Sets.java:133)
[...]
As there is no @NotNull
annotation for it, I assume it is a bug.
* Dexx is currently built with maven. Use
mvn install to build and install into your local repository.
should become
* Dexx is currently built with gradle. Use
./gradlew install to build and install into your local repository.
Not sure what should become of this block:
* By default, a quick version of tests are run. Getting better test coverage of `Vectors` requires large
collections. To run tests with complete coverage use: `mvn -Ddexx.test.mode=COMPLETE -P cobertura clean cobertura:cobertura`
* To run the benchmarks, use `mvn -Ddexx.test.mode=BENCHMARK test` (results are lines starting with BENCHMARK).
The following does not work:
java.util.Map<String, Integer> javaMap = new java.util.HashMap<String, Integer>();
Map<String, Integer> immutableMap = Maps.copyOf(javaMap.entrySet());
Compile error:
build/plugins/java/Dexx.java:20: error: no suitable method found for copyOf(java.util.Map<String,Integer>)
Map<String, Integer> immutableMap = Maps.copyOf(javaMap);
^
method Maps.<K#1,V#1>copyOf(Iterable<Pair<K#1,V#1>>) is not applicable
(cannot infer type-variable(s) K#1,V#1
(argument mismatch; java.util.Map<String,Integer> cannot be converted to Iterable<Pair<K#1,V#1>>))
method Maps.<K#2,V#2>copyOf(Iterator<Pair<K#2,V#2>>) is not applicable
(cannot infer type-variable(s) K#2,V#2
(argument mismatch; java.util.Map<String,Integer> cannot be converted to Iterator<Pair<K#2,V#2>>))
method Maps.<K#3,V#3>copyOf(Pair<K#3,V#3>[]) is not applicable
(cannot infer type-variable(s) K#3,V#3
(argument mismatch; java.util.Map<String,Integer> cannot be converted to Pair<K#3,V#3>[]))
where K#1,V#1,K#2,V#2,K#3,V#3 are type-variables:
K#1 extends Object declared in method <K#1,V#1>copyOf(Iterable<Pair<K#1,V#1>>)
V#1 extends Object declared in method <K#1,V#1>copyOf(Iterable<Pair<K#1,V#1>>)
K#2 extends Object declared in method <K#2,V#2>copyOf(Iterator<Pair<K#2,V#2>>)
V#2 extends Object declared in method <K#2,V#2>copyOf(Iterator<Pair<K#2,V#2>>)
K#3 extends Object declared in method <K#3,V#3>copyOf(Pair<K#3,V#3>[])
V#3 extends Object declared in method <K#3,V#3>copyOf(Pair<K#3,V#3>[])
It would be nice to have a method in Maps that allows to construct a Map from a java.util.Map
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.