1 /* readonlysortedset.vala
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 * Read-only view for {@link SortedSet} collections.
27 * This class decorates any class which implements the {@link SortedSet} interface
28 * by making it read only. Any method which normally modify data will throw an
33 internal class Gee.ReadOnlySortedSet<G> : ReadOnlySet<G>, SortedSet<G> {
35 * Constructs a read-only set that mirrors the content of the specified set.
37 * @param set the set to decorate.
39 public ReadOnlySortedSet (SortedSet<G> set) {
47 return (_collection as SortedSet<G>).first ();
54 return (_collection as SortedSet<G>).last ();
60 public Gee.Iterator<G>? iterator_at (G element) {
61 var iter = (_collection as SortedSet<G>).iterator_at (element);
62 return (iter != null) ? new Iterator<G> (iter) : null;
68 public G? lower (G element) {
69 return (_collection as SortedSet<G>).lower (element);
75 public G? higher (G element) {
76 return (_collection as SortedSet<G>).higher (element);
82 public G? floor (G element) {
83 return (_collection as SortedSet<G>).floor (element);
89 public G? ceil (G element) {
90 return (_collection as SortedSet<G>).ceil (element);
96 public SortedSet<G> head_set (G before) {
97 return (_collection as SortedSet<G>).head_set (before).read_only_view;
103 public SortedSet<G> tail_set (G after) {
104 return(_collection as SortedSet<G>).tail_set (after).read_only_view;
110 public SortedSet<G> sub_set (G from, G to) {
111 return (_collection as SortedSet<G>).sub_set (from, to).read_only_view;
117 public new SortedSet<G> read_only_view {