comparison dwtx/jface/text/link/TabStopIterator.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents f70d9508c95c
children
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
22 import dwtx.jface.text.link.LinkedPositionAnnotations; // packageimport 22 import dwtx.jface.text.link.LinkedPositionAnnotations; // packageimport
23 import dwtx.jface.text.link.ProposalPosition; // packageimport 23 import dwtx.jface.text.link.ProposalPosition; // packageimport
24 24
25 25
26 import dwt.dwthelper.utils; 26 import dwt.dwthelper.utils;
27
28 import dwtx.dwtxhelper.Collection; 27 import dwtx.dwtxhelper.Collection;
29 28 import tango.core.Exception;
30
31
32
33 import java.util.NoSuchElementException;
34 29
35 import dwtx.core.runtime.Assert; 30 import dwtx.core.runtime.Assert;
36 import dwtx.jface.text.Position; 31 import dwtx.jface.text.Position;
37 32
38 33
68 } 63 }
69 64
70 } 65 }
71 66
72 /** The comparator to sort the list of positions. */ 67 /** The comparator to sort the list of positions. */
73 private static const Comparator fComparator= new SequenceComparator(); 68 private static Comparator fComparator_;
69 private static Comparator fComparator(){
70 if( fComparator_ is null ){
71 synchronized( TabStopIterator.classinfo ){
72 if( fComparator_ is null ){
73 fComparator_ = new SequenceComparator();
74 }
75 }
76 }
77 return fComparator_;
78 }
74 79
75 /** The iteration sequence. */ 80 /** The iteration sequence. */
76 private const ArrayList fList; 81 private const ArrayList fList;
77 /** The size of <code>fList</code>. */ 82 /** The size of <code>fList</code>. */
78 private int fSize; 83 private int fSize;
80 private int fIndex; 85 private int fIndex;
81 /** Cycling property. */ 86 /** Cycling property. */
82 private bool fIsCycling= false; 87 private bool fIsCycling= false;
83 88
84 this(List positionSequence) { 89 this(List positionSequence) {
85 Assert.isNotNull(positionSequence); 90 Assert.isNotNull(cast(Object)positionSequence);
86 fList= new ArrayList(positionSequence); 91 fList= new ArrayList(positionSequence);
87 Collections.sort(fList, fComparator); 92 Collections.sort(fList, fComparator);
88 fSize= fList.size(); 93 fSize= fList.size();
89 fIndex= -1; 94 fIndex= -1;
90 Assert.isTrue(fSize > 0); 95 Assert.isTrue(fSize > 0);
190 return -1; 195 return -1;
191 } 196 }
192 197
193 LinkedPosition next(LinkedPosition current) { 198 LinkedPosition next(LinkedPosition current) {
194 if (!hasNext(current)) 199 if (!hasNext(current))
195 throw new NoSuchElementException(); 200 throw new NoSuchElementException(null);
196 return cast(LinkedPosition) fList.get(fIndex= getNextIndex(current)); 201 return cast(LinkedPosition) fList.get(fIndex= getNextIndex(current));
197 } 202 }
198 203
199 LinkedPosition previous(LinkedPosition current) { 204 LinkedPosition previous(LinkedPosition current) {
200 if (!hasPrevious(current)) 205 if (!hasPrevious(current))
201 throw new NoSuchElementException(); 206 throw new NoSuchElementException(null);
202 return cast(LinkedPosition) fList.get(fIndex= getPreviousIndex(current)); 207 return cast(LinkedPosition) fList.get(fIndex= getPreviousIndex(current));
203 } 208 }
204 209
205 void setCycling(bool mode) { 210 void setCycling(bool mode) {
206 fIsCycling= mode; 211 fIsCycling= mode;
222 bool isCycling() { 227 bool isCycling() {
223 return fIsCycling; 228 return fIsCycling;
224 } 229 }
225 230
226 LinkedPosition[] getPositions() { 231 LinkedPosition[] getPositions() {
227 return (LinkedPosition[]) fList.toArray(new LinkedPosition[fSize]); 232 return arraycast!(LinkedPosition)( fList.toArray());
228 } 233 }
229 } 234 }