You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/08/01 03:08:48 UTC
svn commit: r799783 -
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java
Author: gbrown
Date: Sat Aug 1 01:08:47 2009
New Revision: 799783
URL: http://svn.apache.org/viewvc?rev=799783&view=rev
Log:
Various fixes to ListSelection.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java?rev=799783&r1=799782&r2=799783&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ListSelection.java Sat Aug 1 01:08:47 2009
@@ -67,7 +67,7 @@
* A sequence containing the ranges that were added.
*/
public Sequence<Span> addRange(int start, int end) {
- assert(start > 0);
+ assert(start >= 0);
assert(end >= start);
ArrayList<Span> added = new ArrayList<Span>();
@@ -84,7 +84,7 @@
} else {
// Locate the lower bound of the intersection
int i = ArrayList.binarySearch(selectedRanges, range, START_COMPARATOR);
- if (i <= 0) {
+ if (i < 0) {
i = -(i + 1);
}
@@ -104,8 +104,10 @@
} else {
// Locate the upper bound of the intersection
int j = ArrayList.binarySearch(selectedRanges, range, END_COMPARATOR);
- if (j <= 0) {
+ if (j < 0) {
j = -(j + 1);
+ } else {
+ j++;
}
// Merge the selection with the next range, if necessary
@@ -118,6 +120,7 @@
if (i == j) {
selectedRanges.insert(range, i);
+ added.add(range);
} else {
Span lowerRange = selectedRanges.get(i);
Span upperRange = selectedRanges.get(j - 1);
@@ -152,7 +155,7 @@
* A sequence containing the ranges that were removed.
*/
public Sequence<Span> removeRange(int start, int end) {
- assert(start > 0);
+ assert(start >= 0);
assert(end >= start);
ArrayList<Span> removed = new ArrayList<Span>();
@@ -165,7 +168,7 @@
if (n > 0) {
// Locate the lower bound of the intersection
int i = ArrayList.binarySearch(selectedRanges, range, START_COMPARATOR);
- if (i <= 0) {
+ if (i < 0) {
i = -(i + 1);
}
@@ -186,8 +189,10 @@
// Locate the upper bound of the intersection
int j = ArrayList.binarySearch(selectedRanges, range, END_COMPARATOR);
- if (j <= 0) {
+ if (j < 0) {
j = -(j + 1);
+ } else {
+ j++;
}
Span upperRange = selectedRanges.get(j - 1);