本文整理汇总了Java中org.apache.commons.collections4.BidiMap类的典型用法代码示例。如果您正苦于以下问题:Java BidiMap类的具体用法?Java BidiMap怎么用?Java BidiMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BidiMap类属于org.apache.commons.collections4包,在下文中一共展示了BidiMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBidiClear
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Test(timeout = 1000)
public void testBidiClear() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBidiClear");
if (!(isRemoveSupported())) {
try {
makeFullMap().clear();
makeFullMap().clear();
} catch (final UnsupportedOperationException ex) {
}
return ;
}
BidiMap<?, ?> map = makeFullMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4857,map,4856,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4859,map.inverseBidiMap(),4858,map.inverseBidiMap().isEmpty());
map = makeFullMap().inverseBidiMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4861,map,4860,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4863,map.inverseBidiMap(),4862,map.inverseBidiMap().isEmpty());
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例2: testBidiClear_add1568
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Test(timeout = 1000)
public void testBidiClear_add1568() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBidiClear_add1568");
if (!(isRemoveSupported())) {
try {
makeFullMap().clear();
} catch (final UnsupportedOperationException ex) {
}
return ;
}
BidiMap<?, ?> map = makeFullMap();
map.clear();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4857,map,4856,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4859,map.inverseBidiMap(),4858,map.inverseBidiMap().isEmpty());
map = makeFullMap().inverseBidiMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4861,map,4860,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4863,map.inverseBidiMap(),4862,map.inverseBidiMap().isEmpty());
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例3: testBidiClear_add1569
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Test(timeout = 1000)
public void testBidiClear_add1569() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBidiClear_add1569");
if (!(isRemoveSupported())) {
try {
makeFullMap().clear();
} catch (final UnsupportedOperationException ex) {
}
return ;
}
BidiMap<?, ?> map = makeFullMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4857,map,4856,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4859,map.inverseBidiMap(),4858,map.inverseBidiMap().isEmpty());
map = makeFullMap().inverseBidiMap();
map.clear();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4861,map,4860,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4863,map.inverseBidiMap(),4862,map.inverseBidiMap().isEmpty());
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例4: testBidiClear_remove1189
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Test(timeout = 1000)
public void testBidiClear_remove1189() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBidiClear_remove1189");
if (!(isRemoveSupported())) {
try {
makeFullMap().clear();
} catch (final UnsupportedOperationException ex) {
}
return ;
}
BidiMap<?, ?> map = makeFullMap();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4857,map,4856,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4859,map.inverseBidiMap(),4858,map.inverseBidiMap().isEmpty());
map = makeFullMap().inverseBidiMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4861,map,4860,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4863,map.inverseBidiMap(),4862,map.inverseBidiMap().isEmpty());
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例5: testBidiClear_remove1190
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Test(timeout = 1000)
public void testBidiClear_remove1190() {
fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBidiClear_remove1190");
if (!(isRemoveSupported())) {
try {
makeFullMap().clear();
} catch (final UnsupportedOperationException ex) {
}
return ;
}
BidiMap<?, ?> map = makeFullMap();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4857,map,4856,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4859,map.inverseBidiMap(),4858,map.inverseBidiMap().isEmpty());
map = makeFullMap().inverseBidiMap();
map.clear();
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4861,map,4860,map.isEmpty());
fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),4863,map.inverseBidiMap(),4862,map.inverseBidiMap().isEmpty());
fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
示例6: startFollowingActually
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
private synchronized Map.Entry<Follower, Future<Message>> startFollowingActually(
final MidDeliveryMessageCondition<LogWatch> condition) {
if (this.isStopped()) {
throw new IllegalStateException("Cannot start following on an already terminated LogWatch.");
}
// assemble list of consumers to be handing down and then the follower
final List<Pair<String, MessageMeasure<? extends Number, Follower>>> pairs = new ArrayList<>();
for (final BidiMap.Entry<String, MessageMeasure<? extends Number, Follower>> entry : this.handingDown
.entrySet()) {
pairs.add(ImmutablePair.of(entry.getKey(),
entry.getValue()));
}
// register the follower
final Follower follower = new DefaultFollower(this, pairs);
final Future<Message> expectation = condition == null ? null : follower.expect(condition);
this.consumers.registerConsumer(follower);
this.storage.followerStarted(follower);
DefaultLogWatch.LOGGER.info("Registered {} for {}.", follower, this);
return ImmutablePair.of(follower, expectation);
}
示例7: construct
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
private static BidiMap<State, State> construct(TransitionSystem lts1, TransitionSystem lts2, boolean checkLabels) {
// Check trivial case
if (lts1.getNodes().size() != lts2.getNodes().size()) {
return new DualHashBidiMap<>();
}
if (checkLabels) {
boolean precond1 = checkPreconditions(lts1);
boolean precond2 = checkPreconditions(lts2);
if (precond1 != precond2)
// Not isomorphic
return new DualHashBidiMap<>();
if (precond1 && precond2)
// Both lts are totally reachable and deterministic. We can apply a special algorithm.
return checkViaDepthSearch(lts1, lts2);
}
return new IsomorphismLogicComplex(lts1, lts2, checkLabels).getIsomorphism();
}
示例8: inverseBidiMap
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Override
public synchronized BidiMap<V, K> inverseBidiMap() {
if (inverse == null) {
inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap());
inverse.inverse = this;
}
return inverse;
}
示例9: inverseBidiMap
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
@Override
public BidiMap<V, K> inverseBidiMap() {
if (inverseBidiMap == null) {
inverseBidiMap = createBidiMap(reverseMap, normalMap, this);
}
return inverseBidiMap;
}
示例10: encodeInternal
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
private String encodeInternal(String message, BidiMap<Character, Character> substitutionAlphabet) {
StringBuilder result = new StringBuilder();
for (char c : message.toCharArray()) {
Character res = substitutionAlphabet.get(c);
if (res == null)
result.append(c);
else {
result.append(res);
}
}
return result.toString();
}
示例11: generateSubstitutionAlphabet
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
/**
* Generates map of substitution symbols for given language and substitution array
*
* @param language language to generate substitution for
* @param substitutions array of substitution characters
* @return bi-directional map with 1:1 alphabets for given language
*/
public static BidiMap<Character, Character> generateSubstitutionAlphabet(Language language, char[] substitutions) {
char[] languageAlphabet = getAlphabet(language);
if (!ArrayUtils.isSameLength(substitutions, languageAlphabet))
throw new IllegalArgumentException("Substitution array should have same alphabets as given language has");
BidiMap<Character, Character> substitutionAlphabet = new DualHashBidiMap<>();
for (int i = 0; i < languageAlphabet.length; i++) {
char key = languageAlphabet[i];
char value = substitutions[i];
substitutionAlphabet.put(key, value);
}
return substitutionAlphabet;
}
示例12: main
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
public static void main(String[] args) {
String[] englishWords = {"one", "two", "three","ball","snow"};
String[] russianWords = {"jeden", "dwa", "trzy", "kula", "snieg"};
// Create Multiset
BidiMap<String, String> biMap = new DualHashBidiMap();
// Create Polish-English dictionary
int i = 0;
for(String englishWord: englishWords) {
biMap.put(englishWord, russianWords[i]);
i++;
}
// Print count words
System.out.println(biMap); // Print "{ball=kula, snow=snieg, one=jeden, two=dwa, three=trzy}" - in random orders
// Print unique words
System.out.println(biMap.keySet()); // print "[ball, snow, one, two, three]"- in random orders
System.out.println(biMap.values()); // print "[kula, snieg, jeden, dwa, trzy]" - in random orders
// Print translate by words
System.out.println("one = " + biMap.get("one")); // print one = jeden
System.out.println("two = " + biMap.get("two")); // print two = dwa
System.out.println("kula = " + biMap.getKey("kula")); // print kula = ball
System.out.println("snieg = " + biMap.getKey("snieg")); // print snieg = snow
System.out.println("empty = " + biMap.get("empty")); // print empty = null
// Print count word's pair
System.out.println(biMap.size()); //print 5
}
示例13: main
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
public static void main(String[] args) {
String[] englishWords = {"one", "two", "three","ball","snow"};
String[] russianWords = {"jeden", "dwa", "trzy", "kula", "snieg"};
// Создаем Multiset
BidiMap<String, String> biMap = new DualHashBidiMap();
// создаем англо-польский словарь
int i = 0;
for(String englishWord: englishWords) {
biMap.put(englishWord, russianWords[i]);
i++;
}
// Выводим кол-вом вхождений слов
System.out.println(biMap); // напечатает {ball=kula, snow=snieg, one=jeden, two=dwa, three=trzy}- в произвольном порядке
// Выводим все уникальные слова
System.out.println(biMap.keySet()); // напечатает [ball, snow, one, two, three]- в произвольном порядке
System.out.println(biMap.values()); // напечатает [kula, snieg, jeden, dwa, trzy]- в произвольном порядке
// Выводим перевод по каждому слову
System.out.println("one = " + biMap.get("one")); // напечатает one = jeden
System.out.println("two = " + biMap.get("two")); // напечатает two = dwa
System.out.println("kula = " + biMap.getKey("kula")); // напечатает kula = ball
System.out.println("snieg = " + biMap.getKey("snieg")); // напечатает snieg = snow
System.out.println("empty = " + biMap.get("empty")); // напечатает empty = null
// Выводим общее количество переводов в словаре
System.out.println(biMap.size()); //напечатает 5
}
示例14: encode
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
/**
* Encode string.
*
* @param original
* the original
* @return the string
*/
protected String encode(String original) {
BidiMap<String, String> codec = CODEC.get();
String key = codec.getKey(original);
if (key == null) {
key = Integer.toHexString(codec.size());
codec.put(key, original);
}
return key;
}
示例15: getGUILanguageStrings
import org.apache.commons.collections4.BidiMap; //导入依赖的package包/类
/**
*
*
* @return
*/
public BidiMap<String, String> getGUILanguageStrings() {
final BidiMap<String, String> langs = new DualHashBidiMap<String, String>();
final String[] langsFromProp = getProp(AVAILABLE_LOCALES).split(";");
for (String st : langsFromProp) {
final String[] parts = st.split("-");
langs.put(parts[0], parts[1]);
}
return langs;
}