/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/util/IntSet.java
ViewVC logotype

Contents of /android/TrainInfo/src/dk/thoerup/traininfo/util/IntSet.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 433 - (show annotations) (download)
Sat Oct 10 11:30:08 2009 UTC (14 years, 7 months ago) by torben
File size: 697 byte(s)
Added station favorite list
1 package dk.thoerup.traininfo.util;
2
3 import java.util.Set;
4 import java.util.TreeSet;
5
6 public class IntSet {
7 private Set<Integer> ints = new TreeSet<Integer>();
8
9 public boolean hasInt(int i) {
10 return ints.contains(i);
11 }
12
13 public void add(int i) {
14 ints.add(i);
15 }
16
17 public void remove(int i) {
18 ints.remove(i);
19 }
20
21 public String toString() {
22 StringBuffer sb = new StringBuffer();
23
24 for (int i : ints) {
25 if (sb.length() > 0) {
26 sb.append(",");
27 }
28 sb.append(i);
29 }
30
31 return sb.toString();
32 }
33
34 public void fromString(String intStr) {
35 ints.clear();
36 String parts[] = intStr.split(",");
37 for (String istr : parts) {
38 ints.add( Integer.parseInt(istr));
39 }
40 }
41
42 }

  ViewVC Help
Powered by ViewVC 1.1.20