Could anyone explain me conceptually(inner working), what is the difference between jface treeviewer
setComparer
method and setSorter
method.
任何人都可以在概念上解释我(内部工作),jface treeviewer setComparer方法和setSorter方法之间有什么区别。
1 个解决方案
#1
setSorter
is an obsolete method which has been replaced by setComparator
.
setSorter是一个过时的方法,已被setComparator取代。
The ViewerSorter
class used by setSorter
only supported the use of a Collator
for sorting.
setSorter使用的ViewerSorter类仅支持使用Collator进行排序。
The ViewerComparator
class used by setComparator
supports any Comparator
class.
setComparator使用的ViewerComparator类支持任何Comparator类。
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.
当查看器在其内部HashMap中搜索匹配元素时(例如,当您调用refresh(element)时),将使用setComparer方法设置的IElementComparer类。有时,实际对象上的equals和hashCode方法不适合此查找,因此您可以使用IElementComparer来提供替代方法。
So the setComparer
is not used for sorting the view like the setSorter
or setComparator
methods.
因此setComparer不用于对视图进行排序,如setSorter或setComparator方法。
#1
setSorter
is an obsolete method which has been replaced by setComparator
.
setSorter是一个过时的方法,已被setComparator取代。
The ViewerSorter
class used by setSorter
only supported the use of a Collator
for sorting.
setSorter使用的ViewerSorter类仅支持使用Collator进行排序。
The ViewerComparator
class used by setComparator
supports any Comparator
class.
setComparator使用的ViewerComparator类支持任何Comparator类。
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.
当查看器在其内部HashMap中搜索匹配元素时(例如,当您调用refresh(element)时),将使用setComparer方法设置的IElementComparer类。有时,实际对象上的equals和hashCode方法不适合此查找,因此您可以使用IElementComparer来提供替代方法。
So the setComparer
is not used for sorting the view like the setSorter
or setComparator
methods.
因此setComparer不用于对视图进行排序,如setSorter或setComparator方法。