本文整理汇总了Java中gnu.trove.Equality类的典型用法代码示例。如果您正苦于以下问题:Java Equality类的具体用法?Java Equality怎么用?Java Equality使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Equality类属于gnu.trove包,在下文中一共展示了Equality类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NamedItemsListEditor
import gnu.trove.Equality; //导入依赖的package包/类
protected NamedItemsListEditor(Namer<T> namer,
Factory<T> factory,
Cloner<T> cloner,
Equality<T> comparer,
List<T> items,
boolean initInConstructor) {
myNamer = namer;
myFactory = factory;
myCloner = cloner;
myComparer = comparer;
myOriginalItems = items;
myResultItems = items;
if (initInConstructor) {
reset();
initTree();
}
}
示例2: install
import gnu.trove.Equality; //导入依赖的package包/类
public static TreeExpansionMonitor<DefaultMutableTreeNode> install(final JTree tree, final Equality<DefaultMutableTreeNode> equality) {
return new TreeExpansionMonitor<DefaultMutableTreeNode>(tree) {
protected TreePath findPathByNode(final DefaultMutableTreeNode node) {
Enumeration enumeration = ((DefaultMutableTreeNode)tree.getModel().getRoot()).breadthFirstEnumeration();
while (enumeration.hasMoreElements()) {
final Object nextElement = enumeration.nextElement();
if (nextElement instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode child = (DefaultMutableTreeNode)nextElement;
if (equality.equals(child, node)) {
return new TreePath(child.getPath());
}
}
}
return null;
}
};
}
示例3: equals
import gnu.trove.Equality; //导入依赖的package包/类
@Contract(pure=true)
public static <T> boolean equals(@NotNull T[] a1, @NotNull T[] a2, @NotNull Equality<? super T> comparator) {
if (a1 == a2) {
return true;
}
int length = a2.length;
if (a1.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (!comparator.equals(a1[i], a2[i])) {
return false;
}
}
return true;
}
示例4: offerIfAbsent
import gnu.trove.Equality; //导入依赖的package包/类
public boolean offerIfAbsent(@NotNull final T thing, @NotNull final Equality<T> equality) {
boolean absent;
synchronized (myQueue) {
absent = myQueue.process(new Processor<T>() {
@Override
public boolean process(T t) {
return !equality.equals(t, thing);
}
});
if (absent) {
myQueue.addLast(thing);
scheduleUpdate();
}
}
return absent;
}
示例5: equals
import gnu.trove.Equality; //导入依赖的package包/类
public static <T> boolean equals(T[] a1, T[] a2, @NotNull Equality<? super T> comparator) {
if (a1 == a2) {
return true;
}
if (a1 == null || a2 == null) {
return false;
}
int length = a2.length;
if (a1.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (!comparator.equals(a1[i], a2[i])) {
return false;
}
}
return true;
}
示例6: equals
import gnu.trove.Equality; //导入依赖的package包/类
@Contract(pure=true)
public static <T> boolean equals(@Nonnull T[] a1, @Nonnull T[] a2, @Nonnull Equality<? super T> comparator) {
//noinspection ArrayEquality
if (a1 == a2) {
return true;
}
int length = a2.length;
if (a1.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (!comparator.equals(a1[i], a2[i])) {
return false;
}
}
return true;
}
示例7: RangeIterator
import gnu.trove.Equality; //导入依赖的package包/类
public RangeIterator(Gaps foldingModel, Equality<TextAttributes> equality,
HighlighterIterator source, Condition<TextAttributes> filter) {
mySource = source;
myGaps = foldingModel;
myEquality = equality;
myFilter = filter;
}
示例8: testExtractWords
import gnu.trove.Equality; //导入依赖的package包/类
public void testExtractWords() {
String text = "a b, c.d\n\n x\n y";
Word[] words = ByWord.buildWords(text, ComparisonPolicy.DEFAULT);
CHECK.setEquality(new Equality() {
@Override
public boolean equals(Object o1, Object o2) {
Word word1 = (Word)o1;
Word word2 = (Word)o2;
return word1.getStart() == word2.getStart() && word1.getEnd() == word2.getEnd();
}
});
CHECK.setStringConvertion(StringConvertion.DEFAULT);
CHECK.compareAll(new Word[]{new Formatting(text, new TextRange(0, 0)),
new Word(text, new TextRange(0, 1)),
new Word(text, new TextRange(2, 3)),
new Word(text, new TextRange(5, 6)),
new Word(text, new TextRange(7, 8)),
new Formatting(text, new TextRange(8, 12)),
new Word(text, new TextRange(12, 13)),
new Formatting(text, new TextRange(13, 15)),
new Word(text, new TextRange(15, 16))}, words);
text = " b c";
words = ByWord.buildWords(text, ComparisonPolicy.DEFAULT);
CHECK.compareAll(new Word[]{new Formatting(text, new TextRange(0, 1)),
new Word(text, new TextRange(1, 2)),
new Word(text, new TextRange(3, 4))}, words);
}
示例9: createIterator
import gnu.trove.Equality; //导入依赖的package包/类
private RangeIterator createIterator(Equality equality, int[] starts, int[] ends, RangeIterator.Gaps gaps) {
RangeIterator iterator = new RangeIterator(gaps, equality,
new MyHighlighterIterator(starts, ends), ANY);
iterator.init(new TextRange(0, Integer.MAX_VALUE));
iterator.advance();
return iterator;
}
示例10: offerIfAbsent
import gnu.trove.Equality; //导入依赖的package包/类
public boolean offerIfAbsent(@NotNull final T thing, @NotNull final Equality<T> equality) {
synchronized (myQueue) {
boolean absent = myQueue.process(new Processor<T>() {
@Override
public boolean process(T t) {
return !equality.equals(t, thing);
}
});
if (absent) {
myQueue.addLast(thing);
scheduleUpdate();
}
return absent;
}
}
示例11: indexOf
import gnu.trove.Equality; //导入依赖的package包/类
@Contract(pure=true)
public static <T> int indexOf(@NotNull List<T> objects, T object, @NotNull Equality<T> comparator) {
for (int i = 0; i < objects.size(); i++) {
if (comparator.equals(objects.get(i), object)) return i;
}
return -1;
}
示例12: lastIndexOf
import gnu.trove.Equality; //导入依赖的package包/类
@Contract(pure=true)
public static <T> int lastIndexOf(@NotNull final T[] src, final T obj, @NotNull Equality<? super T> comparator) {
for (int i = src.length - 1; i >= 0; i--) {
final T o = src[i];
if (comparator.equals(obj, o)) {
return i;
}
}
return -1;
}
示例13: mergeDescriptors
import gnu.trove.Equality; //导入依赖的package包/类
@NotNull
private static CommonProblemDescriptor[] mergeDescriptors(@NotNull CommonProblemDescriptor[] problems1,
@NotNull CommonProblemDescriptor[] problems2) {
CommonProblemDescriptor[] out = new CommonProblemDescriptor[problems1.length + problems2.length];
int o = problems1.length;
Equality<CommonProblemDescriptor> equality = new Equality<CommonProblemDescriptor>() {
@Override
public boolean equals(CommonProblemDescriptor o1, CommonProblemDescriptor o2) {
if (o1 instanceof ProblemDescriptor) {
ProblemDescriptorBase p1 = (ProblemDescriptorBase)o1;
ProblemDescriptorBase p2 = (ProblemDescriptorBase)o2;
if (!Comparing.equal(p1.getDescriptionTemplate(), p2.getDescriptionTemplate())) return false;
if (!Comparing.equal(p1.getTextRange(), p2.getTextRange())) return false;
if (!Comparing.equal(p1.getHighlightType(), p2.getHighlightType())) return false;
if (!Comparing.equal(p1.getProblemGroup(), p2.getProblemGroup())) return false;
if (!Comparing.equal(p1.getStartElement(), p2.getStartElement())) return false;
if (!Comparing.equal(p1.getEndElement(), p2.getEndElement())) return false;
}
else {
if (!o1.toString().equals(o2.toString())) return false;
}
return true;
}
};
for (CommonProblemDescriptor descriptor : problems2) {
if (ArrayUtil.indexOf(problems1, descriptor, equality) == -1) {
out[o++] = descriptor;
}
}
System.arraycopy(problems1, 0, out, 0, problems1.length);
return Arrays.copyOfRange(out, 0, o);
}
示例14: assertEquals
import gnu.trove.Equality; //导入依赖的package包/类
public void assertEquals(String[][] expected) {
String[][] actual = myResults.toArray(new String[myResults.size()][]);
boolean equals = ArrayUtil.equals(actual, expected, new Equality<String[]>() {
public boolean equals(String[] o1, String[] o2) {
return Arrays.equals(o1, o2);
}
});
StringBuilder message = new StringBuilder("Expected: ");
toString(expected, message);
message.append("\nActual: ");
toString(actual, message);
Assert.assertTrue(message.toString(), equals);
}
示例15: getMergeType
import gnu.trove.Equality; //导入依赖的package包/类
@Nonnull
public static MergeConflictType getMergeType(@Nonnull Condition<ThreeSide> emptiness,
@Nonnull Equality<ThreeSide> equality) {
boolean isLeftEmpty = emptiness.value(ThreeSide.LEFT);
boolean isBaseEmpty = emptiness.value(ThreeSide.BASE);
boolean isRightEmpty = emptiness.value(ThreeSide.RIGHT);
assert !isLeftEmpty || !isBaseEmpty || !isRightEmpty;
if (isBaseEmpty) {
if (isLeftEmpty) { // --=
return new MergeConflictType(TextDiffType.INSERTED, false, true);
}
else if (isRightEmpty) { // =--
return new MergeConflictType(TextDiffType.INSERTED, true, false);
}
else { // =-=
boolean equalModifications = equality.equals(ThreeSide.LEFT, ThreeSide.RIGHT);
return new MergeConflictType(equalModifications ? TextDiffType.INSERTED : TextDiffType.CONFLICT);
}
}
else {
if (isLeftEmpty && isRightEmpty) { // -=-
return new MergeConflictType(TextDiffType.DELETED);
}
else { // -==, ==-, ===
boolean unchangedLeft = equality.equals(ThreeSide.BASE, ThreeSide.LEFT);
boolean unchangedRight = equality.equals(ThreeSide.BASE, ThreeSide.RIGHT);
assert !unchangedLeft || !unchangedRight;
if (unchangedLeft) return new MergeConflictType(isRightEmpty ? TextDiffType.DELETED : TextDiffType.MODIFIED, false, true);
if (unchangedRight) return new MergeConflictType(isLeftEmpty ? TextDiffType.DELETED : TextDiffType.MODIFIED, true, false);
boolean equalModifications = equality.equals(ThreeSide.LEFT, ThreeSide.RIGHT);
return new MergeConflictType(equalModifications ? TextDiffType.MODIFIED : TextDiffType.CONFLICT);
}
}
}