3 * Copyright (C) 2009 Didier Villevalois, Maciej Piechotka
4 * Copyright (C) 2011 Maciej Piechotka
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Maciej Piechotka <uzytkownik2@gmail.com>
25 * A sorted set, which you can navigate over and get sub-sets of.
28 public interface Gee.SortedSet<G> : Gee.Set<G> {
30 * Returns the first element of the sorted set. Set must not be empty.
32 * @return the first element in the sorted set
34 public abstract G first ();
37 * Returns the last element of the sorted set. Set must not be empty.
39 * @return the last element in the sorted set
41 public abstract G last ();
44 * Returns a {@link BidirIterator} initialy pointed at the specified
47 * @param element the element to point the iterator at
49 * @return a {@link BidirIterator} over this sorted set, or null if
50 * the specified element is not in this set
52 public abstract Iterator<G>? iterator_at (G element);
55 * Returns the element which is strictly lower than the specified element.
57 * @param element the element which you want the lower element for
59 * @return the corresponding element
61 public abstract G? lower (G element);
64 * Returns the element which is strictly higher than the specified element.
66 * @param element the element which you want the strictly higher element
69 * @return the corresponding element
71 public abstract G? higher (G element);
74 * Returns the element which is lower or equal then the specified element.
76 * @param element the element which you want the lower or equal element for
78 * @return the corresponding element
80 public abstract G? floor (G element);
83 * Returns the element which is higher or equal then the specified element.
85 * @param element the element which you want the higher or equal element
88 * @return the corresponding element
90 public abstract G? ceil (G element);
93 * Returns the sub-set of this sorted set containing elements strictly
94 * lower than the specified element.
96 * @param before the lower inclusive bound for the sub-set
98 * @return the corresponding sub-set of this sorted set
100 public abstract SortedSet<G> head_set (G before);
103 * Returns the sub-set of this sorted set containing elements equal or
104 * higher than the specified element.
106 * @param after the higher exclusive bound for the sub-set
108 * @return the corresponding sub-set of this sorted set
110 public abstract SortedSet<G> tail_set (G after);
113 * Returns the right-open sub-set of this sorted set, thus containing
114 * elements equal or higher than the specified ``from`` element, and stricly
115 * lower than the specified ``to`` element.
117 * @param from the lower inclusive bound for the sub-set
118 * @param to the higher exclusive bound for the sub-set
120 * @return the corresponding sub-set of this sorted set
122 public abstract SortedSet<G> sub_set (G from, G to);
125 * The read-only view of this set.
127 public abstract new SortedSet<G> read_only_view { owned get; }
130 * Returns an immutable empty sorted set.
132 * @return an immutable empty sorted set
134 public static SortedSet<G> empty<G> () {
135 return new TreeSet<G> ().read_only_view;