KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bak > pcj > set > BooleanSortedSet


1 /*
2  * Primitive Collections for Java.
3  * Copyright (C) 2003 Søren Bak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package bak.pcj.set;
20
21 /**
22  * This interface defines extends the BooleanSet interface to define
23  * sorted sets.
24  *
25  * @see java.util.SortedSet
26  *
27  * @author Søren Bak
28  * @version 1.0 2002/12/04
29  * @since 1.2
30  */

31 public interface BooleanSortedSet extends BooleanSet {
32
33     /**
34      * Adds an element to this set.
35      *
36      * @param v
37      * the element to add to this set.
38      *
39      * @return <tt>true</tt> if this set was modified
40      * as a result of adding <tt>v</tt>; returns
41      * <tt>false</tt> otherwise.
42      *
43      * @throws UnsupportedOperationException
44      * if the operation is not supported by this
45      * set.
46      *
47      * @throws IllegalArgumentException
48      * if <tt>v</tt> is not permitted, because this set
49      * is a subset of another set.
50      */

51     boolean add(boolean v);
52
53     /**
54      * Returns the lowest element of this set.
55      *
56      * @return the lowest element of this set.
57      *
58      * @throws NoSuchElementException
59      * if this set is empty.
60      */

61     boolean first();
62
63     /**
64      * Returns the subset of values lower than a specified value.
65      * The returned subset is a view of this set, so changes to the
66      * subset are reflected by this set and vice versa.
67      *
68      * @param to
69      * the upper bound of the returned set (not included).
70      *
71      * @throws IllegalArgumentException
72      * if <tt>to</tt> is not permitted
73      * in this set (which can be the case with returned
74      * subsets).
75      */

76     BooleanSortedSet headSet(boolean to);
77
78     /**
79      * Returns the highest element of this set.
80      *
81      * @return the highest element of this set.
82      *
83      * @throws NoSuchElementException
84      * if this set is empty.
85      */

86     boolean last();
87
88     /**
89      * Returns the subset of values lower that a specified value and
90      * higher than or equal to another specified value.
91      * The returned subset is a view of this set, so changes to the
92      * subset are reflected by this set and vice versa.
93      *
94      * @param from
95      * the lower bound of the returned set (included).
96      *
97      * @param to
98      * the upper bound of the returned set (not included).
99      *
100      * @throws IllegalArgumentException
101      * if <tt>from</tt> is greater than <tt>to</tt>;
102      * if <tt>from</tt> or <tt>to</tt> is not permitted
103      * in this set (which can be the case with returned
104      * subsets).
105      */

106     BooleanSortedSet subSet(boolean from, boolean to);
107
108     /**
109      * Returns the subset of values higher than or equal to a
110      * specified value.
111      * The returned subset is a view of this set, so changes to the
112      * subset are reflected by this set and vice versa.
113      *
114      * @param from
115      * the lower bound of the returned set (included).
116      *
117      * @throws IllegalArgumentException
118      * if <tt>from</tt> is not permitted
119      * in this set (which can be the case with returned
120      * subsets).
121      */

122     BooleanSortedSet tailSet(boolean from);
123
124 }
Popular Tags