找到你要的答案

Q:What is the difference between jface treeviewer setComparer method and setSorter method?

Q:jface treeviewer setcomparer方法和setsorter方法之间的区别是什么?

Could anyone explain me conceptually(inner working), what is the difference between jface treeviewer setComparer method and setSorter method.

谁能解释我的概念(内部工作),之间的区别是什么setcomparer jface treeviewer方法和setsorter方法。

answer1: 回答1:

setSorter is an obsolete method which has been replaced by setComparator.

The ViewerSorter class used by setSorter only supported the use of a Collator for sorting.

The ViewerComparator class used by setComparator supports any Comparator class.

The IElementComparer class set by the setComparer method is used when the viewer is searching its internal HashMap for matching elements (such as when you call refresh(element)). Sometimes the equals and hashCode methods on the actual object are not be suitable for this lookup so you can use the IElementComparer to provide alternatives.

So the setComparer is not used for sorting the view like the setSorter or setComparator methods.

setsorter是已被取代的setcomparator过时的方法。

通过setsorter仅支持排序的配页机的使用viewersorter类。

用setcomparator的viewercomparator类支持任何比较器类。

由setcomparer方法ielementcomparer班时使用的浏览器是搜索其内部的HashMap匹配元素(例如当你调用刷新(元))。有时在实际对象equals和hashCode方法是不适合这个查找,可以使用ielementcomparer提供替代品。

所以setcomparer不是用来排序的视图像setsorter或setcomparator方法。

java  eclipse-plugin  eclipse-rcp  jface