diff options
Diffstat (limited to 'songdbj/org/tritonus/share/ArraySet.java')
-rw-r--r-- | songdbj/org/tritonus/share/ArraySet.java | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/share/ArraySet.java b/songdbj/org/tritonus/share/ArraySet.java new file mode 100644 index 0000000000..5aa677364f --- /dev/null +++ b/songdbj/org/tritonus/share/ArraySet.java | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | * ArraySet.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 1999 -2004 by Matthias Pfisterer | ||
9 | * | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU Library General Public License as published | ||
13 | * by the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU Library General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU Library General Public | ||
22 | * License along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | /* | ||
28 | |<--- this code is formatted to fit into 80 columns --->| | ||
29 | */ | ||
30 | |||
31 | package org.tritonus.share; | ||
32 | |||
33 | import java.util.ArrayList; | ||
34 | import java.util.Collection; | ||
35 | import java.util.Set; | ||
36 | |||
37 | |||
38 | |||
39 | public class ArraySet<E> | ||
40 | extends ArrayList<E> | ||
41 | implements Set<E> | ||
42 | { | ||
43 | public ArraySet() | ||
44 | { | ||
45 | super(); | ||
46 | } | ||
47 | |||
48 | |||
49 | |||
50 | public ArraySet(Collection<E> c) | ||
51 | { | ||
52 | this(); | ||
53 | addAll(c); | ||
54 | } | ||
55 | |||
56 | |||
57 | |||
58 | public boolean add(E element) | ||
59 | { | ||
60 | if (!contains(element)) | ||
61 | { | ||
62 | super.add(element); | ||
63 | return true; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | return false; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | |||
72 | |||
73 | public void add(int index, E element) | ||
74 | { | ||
75 | throw new UnsupportedOperationException("ArraySet.add(int index, Object element) unsupported"); | ||
76 | } | ||
77 | |||
78 | public E set(int index, E element) | ||
79 | { | ||
80 | throw new UnsupportedOperationException("ArraySet.set(int index, Object element) unsupported"); | ||
81 | } | ||
82 | |||
83 | } | ||
84 | |||
85 | |||
86 | |||
87 | /*** ArraySet.java ***/ | ||