Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: client/samples/swarm/BiIterator.dart

Issue 9314024: Final CL to kill off client/samples . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/samples/swarm/App.dart ('k') | client/samples/swarm/CSS.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /**
2 * An iterator that allows the user to move forward and backward though
3 * a set of items. (Bi-directional)
4 */
5 class BiIterator<E> {
6
7 /**
8 * Provides forward and backward iterator functionality to keep track
9 * which item is currently selected.
10 */
11 ObservableValue<int> currentIndex;
12
13 /**
14 * The collection of items we will be iterating through.
15 */
16 List<E> list;
17
18 BiIterator(this.list, [List<ChangeListener> oldListeners = null])
19 : currentIndex = new ObservableValue<int>(0) {
20 if (oldListeners != null) {
21 currentIndex.listeners = oldListeners;
22 }
23 }
24
25 /**
26 * Returns the next section from the sections, given the current
27 * position. Returns the last source if there is no next section.
28 */
29 E next() {
30 if (currentIndex.value < list.length - 1) {
31 currentIndex.value += 1;
32 }
33 return list[currentIndex.value];
34 }
35
36 /**
37 * Returns the current Section (page in the UI) that the user is
38 * looking at.
39 */
40 E get current() {
41 return list[currentIndex.value];
42 }
43
44 /**
45 * Returns the previous section from the sections, given the current
46 * position. Returns the front section if we are already at the front of
47 * the list.
48 */
49 E previous() {
50 if (currentIndex.value > 0) {
51 currentIndex.value -= 1;
52 }
53 return list[currentIndex.value];
54 }
55
56 /**
57 * Move the iterator pointer over so that it points to a given list item.
58 */
59 void jumpToValue(E val) {
60 for (int i = 0; i < list.length; i++) {
61 if (list[i] === val) {
62 currentIndex.value = i;
63 break;
64 }
65 }
66 }
67 }
OLDNEW
« no previous file with comments | « client/samples/swarm/App.dart ('k') | client/samples/swarm/CSS.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698