Description
A DESCRIPTION OF THE REQUEST :
SortedList.getSourceIndex(int) allows translation from view index to source index. However, there is no way to determine view index from source. "sourceList.indexOf(sortedList.get(viewIdx))" (a) is inefficient and (b) won't work for lists with duplicate items.
JUSTIFICATION :
SortedList is a general purpose class. Mapping between model and view indices is its primary purpose so this functionality should be exposed. At present, relevant code is private (thus inaccessible to even subclasses).
Sample use-case: controls may be backed by SortedList populated with immutable items. In this case, user updates trigger list element replacements rather than in-place modifications. Developer must be able to identify index within source list.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Add "public int getViewIndex(int index)" to SortedList. Possibly add corresponding abstract method to TransformationList as well.
ACTUAL -
No such method.
SortedList.getSourceIndex(int) allows translation from view index to source index. However, there is no way to determine view index from source. "sourceList.indexOf(sortedList.get(viewIdx))" (a) is inefficient and (b) won't work for lists with duplicate items.
JUSTIFICATION :
SortedList is a general purpose class. Mapping between model and view indices is its primary purpose so this functionality should be exposed. At present, relevant code is private (thus inaccessible to even subclasses).
Sample use-case: controls may be backed by SortedList populated with immutable items. In this case, user updates trigger list element replacements rather than in-place modifications. Developer must be able to identify index within source list.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Add "public int getViewIndex(int index)" to SortedList. Possibly add corresponding abstract method to TransformationList as well.
ACTUAL -
No such method.
Attachments
Issue Links
- relates to
-
JDK-8157012 Cleanup whitespace after fix for JDK-8139848
-
- Resolved
-