home *** CD-ROM | disk | FTP | other *** search
- package allaire.util;
-
- public class InsertionSort {
- SortCallback caller;
- int position;
- int rows;
- int maxrows;
- int[] index;
- Object[] elem;
-
- public InsertionSort(int var1) {
- this.maxrows = var1;
- this.index = new int[var1];
- this.elem = new Object[var1];
- }
-
- public void sort() {
- if (this.caller != null) {
- for(int var1 = 1; var1 < this.rows; ++var1) {
- for(int var2 = var1 - 1; var2 >= 0 && this.caller.Compare(this.elem[this.index[var2]], this.elem[this.index[var2 + 1]]) > 0; --var2) {
- int var3 = this.index[var2 + 1];
- this.index[var2 + 1] = this.index[var2];
- this.index[var2] = var3;
- }
- }
-
- }
- }
-
- public Object getnextrow() {
- return ++this.position < this.rows ? this.elem[this.index[this.position]] : null;
- }
-
- public Object getfirstrow() {
- this.position = 0;
- return this.position < this.rows ? this.elem[this.index[this.position]] : null;
- }
-
- public void setSortCallbackHandler(SortCallback var1) {
- this.caller = var1;
- }
-
- public boolean addrow(Object var1) {
- if (this.rows < this.maxrows) {
- this.elem[this.rows] = var1;
- this.index[this.rows] = this.rows++;
- return true;
- } else {
- return false;
- }
- }
- }
-