mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 14:05:32 +00:00
ICU-21757 Remove ICU dependencies on CollectionUtilities
This commit is contained in:
parent
6e6b576729
commit
6041c249f4
5 changed files with 40 additions and 13 deletions
|
@ -22,7 +22,6 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.JUnit4;
|
||||
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.impl.ICUDebug;
|
||||
import com.ibm.icu.impl.Row;
|
||||
import com.ibm.icu.impl.Row.R4;
|
||||
|
@ -384,7 +383,8 @@ public class AlphabeticIndexTest extends TestFmwk {
|
|||
indexCharacters2.addLabels((UnicodeSet)test[i]);
|
||||
}
|
||||
}
|
||||
List<Bucket<Double>> buckets = CollectionUtilities.addAll(alphabeticIndex.iterator(), new ArrayList<Bucket<Double>>());
|
||||
List<Bucket<Double>> buckets = new ArrayList<>(alphabeticIndex.getBucketCount());
|
||||
alphabeticIndex.iterator().forEachRemaining(buckets::add);
|
||||
logln(buckets.toString());
|
||||
}
|
||||
assertEquals(LabelType.OVERFLOW + "\t" + printList, 1, counter.get(LabelType.OVERFLOW));
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Comparator;
|
|||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -44,7 +45,6 @@ import org.junit.runners.JUnit4;
|
|||
|
||||
import com.ibm.icu.dev.test.CoreTestFmwk;
|
||||
import com.ibm.icu.dev.test.serializable.SerializableTestUtility;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.impl.Relation;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.impl.number.DecimalQuantity;
|
||||
|
@ -1505,12 +1505,31 @@ public class PluralRulesTest extends CoreTestFmwk {
|
|||
}
|
||||
};
|
||||
|
||||
private static final Comparator<Collection<StandardPluralCategories>> STDPLURALCATEG_COLLECTION_COMPARATOR = (o1, o2) -> {
|
||||
int diff = o1.size() - o2.size();
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
Iterator<StandardPluralCategories> iterator1 = o1.iterator();
|
||||
Iterator<StandardPluralCategories> iterator2 = o2.iterator();
|
||||
while (true) {
|
||||
// We already know they have the same length, we tested if first thing.
|
||||
if (!iterator1.hasNext() || !iterator2.hasNext()) {
|
||||
// At the end of both iterators, and everything was equal until here.
|
||||
return 0;
|
||||
}
|
||||
diff = iterator1.next().compareTo(iterator2.next());
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void generateLOCALE_SNAPSHOT() {
|
||||
Comparator c = new CollectionUtilities.CollectionComparator<>();
|
||||
Relation<Set<StandardPluralCategories>, PluralRules> setsToRules = Relation.of(
|
||||
new TreeMap<Set<StandardPluralCategories>, Set<PluralRules>>(c), TreeSet.class, PLURAL_RULE_COMPARATOR);
|
||||
new TreeMap<>(STDPLURALCATEG_COLLECTION_COMPARATOR), TreeSet.class, PLURAL_RULE_COMPARATOR);
|
||||
Relation<PluralRules, ULocale> data = Relation.of(
|
||||
new TreeMap<PluralRules, Set<ULocale>>(PLURAL_RULE_COMPARATOR), TreeSet.class);
|
||||
new TreeMap<>(PLURAL_RULE_COMPARATOR), TreeSet.class);
|
||||
for (ULocale locale : PluralRules.getAvailableULocales()) {
|
||||
PluralRules pr = PluralRules.forLocale(locale);
|
||||
EnumSet<StandardPluralCategories> set = getCanonicalSet(pr.getKeywords());
|
||||
|
@ -1523,7 +1542,8 @@ public class PluralRulesTest extends CoreTestFmwk {
|
|||
System.out.println("\n // " + set);
|
||||
for (PluralRules rule : rules) {
|
||||
Set<ULocale> locales = data.get(rule);
|
||||
System.out.print(" \"" + CollectionUtilities.join(locales, ","));
|
||||
String toShow = locales.stream().map(ULocale::toString).collect(Collectors.joining(","));
|
||||
System.out.print(" \"" + toShow);
|
||||
for (StandardPluralCategories spc : set) {
|
||||
String keyword = spc.toString();
|
||||
DecimalQuantitySamples samples = rule.getDecimalSamples(keyword, SampleType.INTEGER);
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -31,7 +32,6 @@ import org.junit.runners.JUnit4;
|
|||
|
||||
import com.ibm.icu.dev.test.CoreTestFmwk;
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.impl.SortedSetRelation;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.lang.CharacterProperties;
|
||||
|
@ -2649,7 +2649,11 @@ public class UnicodeSetTest extends CoreTestFmwk {
|
|||
@Test
|
||||
public void TestIteration() {
|
||||
UnicodeSet us1 = new UnicodeSet("[abcM{xy}]");
|
||||
assertEquals("", "M, a-c", CollectionUtilities.join(us1.ranges(), ", "));
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (EntryRange range : us1.ranges()) {
|
||||
joiner.add(range.toString());
|
||||
}
|
||||
assertEquals("", "M, a-c", joiner.toString());
|
||||
|
||||
// Sample code
|
||||
for (@SuppressWarnings("unused") EntryRange range : us1.ranges()) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.util.Objects;
|
|||
|
||||
import com.ibm.icu.dev.test.AbstractTestLog;
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.impl.locale.XCldrStub.FileUtilities;
|
||||
import com.ibm.icu.impl.locale.XCldrStub.Splitter;
|
||||
import com.ibm.icu.util.ICUUncheckedIOException;
|
||||
|
@ -46,7 +45,7 @@ abstract public class DataDrivenTestHelper {
|
|||
} else {
|
||||
String first = components.iterator().next();
|
||||
String sep = first.startsWith("@") ? "=" : SEPARATOR;
|
||||
out.append(CollectionUtilities.join(components, sep));
|
||||
out.append(String.join(sep, components));
|
||||
if (!comment.isEmpty()) {
|
||||
out.append("\t# ").append(comment);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -27,7 +28,6 @@ import org.junit.runners.JUnit4;
|
|||
|
||||
import com.ibm.icu.dev.test.TestBoilerplate;
|
||||
import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.dev.util.CollectionUtilities;
|
||||
import com.ibm.icu.dev.util.UnicodeMap;
|
||||
import com.ibm.icu.dev.util.UnicodeMap.EntryRange;
|
||||
import com.ibm.icu.dev.util.UnicodeMapIterator;
|
||||
|
@ -66,7 +66,11 @@ public class UnicodeMapTest extends TestFmwk {
|
|||
}
|
||||
|
||||
public void checkToString(UnicodeMap<Double> foo, String expected) {
|
||||
assertEquals("EntryRange<T>", expected, CollectionUtilities.join(foo.entryRanges(), "\n") + (foo.size() == 0 ? "" : "\n"));
|
||||
StringJoiner joiner = new StringJoiner("\n");
|
||||
for (EntryRange range : foo.entryRanges()) {
|
||||
joiner.add(range.toString());
|
||||
}
|
||||
assertEquals("EntryRange<T>", expected, joiner.toString() + (foo.size() == 0 ? "" : "\n"));
|
||||
assertEquals("EntryRange<T>", expected, foo.toString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue