Skip to content

Commit

Permalink
use list instead of set.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Jul 16, 2024
1 parent 153aca5 commit 071e16d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.infumia.pack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

/**
* A factory for creating arbitrary characters, ensuring that reserved characters are not produced.
Expand Down Expand Up @@ -59,7 +59,7 @@ public char create() throws IllegalStateException {
private static final class Internal {

private static final Lazy<Collection<Character>> RESERVED = Lazy.of(() -> {
final Collection<Character> reserved = new HashSet<>();
final Collection<Character> reserved = new ArrayList<>();
for (char c = 'a'; c <= 'z'; c++) {
reserved.add(c);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.infumia.pack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Optional;
import java.util.stream.Collectors;
import net.kyori.adventure.key.Key;
Expand Down Expand Up @@ -31,14 +31,14 @@ private FileResourceMergerDefault() {}

@Override
public Collection<FileResource> merge(final Collection<FileResource> resources) {
final Collection<FileResource> simplified = new HashSet<>(resources.size());
final Collection<FileResource> simplified = new ArrayList<>(resources.size());
for (final FileResource resource : resources) {
simplified.addAll(this.simplify(resource));
}

final MultiMap<Key, Atlas> atlases = new MultiMap<>();
final MultiMap<Key, Model> models = new MultiMap<>();
final HashSet<FileResource> remaining = new HashSet<>();
final Collection<FileResource> remaining = new ArrayList<>();
for (final FileResource resource : simplified) {
if (resource instanceof FileResourceAtlas) {
final Atlas atlas = ((FileResourceAtlas) resource).atlas;
Expand All @@ -53,7 +53,7 @@ public Collection<FileResource> merge(final Collection<FileResource> resources)
}
}

final Collection<Atlas> mergedAtlases = new HashSet<>(atlases.keys().size());
final Collection<Atlas> mergedAtlases = new ArrayList<>(atlases.keys().size());
for (final Key key : atlases.keys()) {
final Collection<Atlas> duplicates = atlases.get(key);
final Atlas merged = Atlas.atlas()
Expand All @@ -69,7 +69,7 @@ public Collection<FileResource> merge(final Collection<FileResource> resources)
mergedAtlases.add(merged);
}

final Collection<Model> mergedModels = new HashSet<>(models.keys().size());
final Collection<Model> mergedModels = new ArrayList<>(models.keys().size());
for (final Key key : models.keys()) {
final Collection<Model> duplicates = models.get(key);
final Model.Builder builder = Model.model().key(key);
Expand Down Expand Up @@ -97,9 +97,9 @@ public Collection<FileResource> merge(final Collection<FileResource> resources)
final Collection<FileResource> mergedResources = mergedAtlases
.stream()
.map(FileResources::atlas)
.collect(Collectors.toSet());
.collect(Collectors.toList());
mergedResources.addAll(
mergedModels.stream().map(FileResources::model).collect(Collectors.toSet())
mergedModels.stream().map(FileResources::model).collect(Collectors.toList())
);
mergedResources.addAll(remaining);
return mergedResources;
Expand All @@ -110,7 +110,7 @@ private Collection<FileResource> simplify(final FileResource resource) {
return ((FileResourceAll) resource).resources.stream()
.map(this::simplify)
.flatMap(Collection::stream)
.collect(Collectors.toSet());
.collect(Collectors.toList());
} else {
return Collections.singletonList(resource);
}
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/net/infumia/pack/MultiMap.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.infumia.pack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

final class MultiMap<K, V> {
Expand All @@ -12,7 +12,7 @@ final class MultiMap<K, V> {
MultiMap() {}

void put(final K key, final V value) {
this.map.computeIfAbsent(key, __ -> new HashSet<>()).add(value);
this.map.computeIfAbsent(key, __ -> new ArrayList<>()).add(value);
}

Collection<V> get(final K key) {
Expand Down
4 changes: 2 additions & 2 deletions generator/src/main/java/net/infumia/pack/PackReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ private PackGeneratorContext read0(@NotNull final Stream<Path> walking) throws I
.readAll()
.stream()
.map(part -> part.directory(path))
.collect(Collectors.toSet());
.collect(Collectors.toList());
}
} catch (final IOException e) {
throw new RuntimeException(e);
}
})
.flatMap(Collection::stream)
.collect(Collectors.toSet());
.collect(Collectors.toList());
return new PackGeneratorContext(
ResourcePack.resourcePack(),
this.base,
Expand Down

0 comments on commit 071e16d

Please sign in to comment.