Java – a class that describes immutable ordered sets

I need some class / interface names that describe immutable ordered sets (in input order, such as linkedhashset) Of course I can use this class like this:

class Foo {
    public final Set<Long> frozenOrderedSet;

    public Foo(List<Long> input) {
        frozenOrderedSet = Collections.unmodifiableSet(new LinkedHashSet(input));
    }
}

But that won't clarify my approach I want to make it clear to everyone that set is immutable and unique, and keep its order with for (long l: Set) {}

Solution

Guava's immutableset provides a high-performance, immutable set with reliable, user specified iteration order There are also changes like immutablesortedset

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>