1 /* readonlybidirsortedset.vala
3 * Copyright (C) 2012 Maciej Piechotka
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Maciej Piechotka <uzytkownik2@gmail.com>
24 * Read-only view for {@link BidirSortedSet} collections.
26 * This class decorates any class which implements the {@link BidirSortedSet}
27 * interface by making it read only. Any method which normally modify data will
32 internal class Gee.ReadOnlyBidirSortedSet<G> : ReadOnlySortedSet<G>, BidirSortedSet<G> {
34 * Constructs a read-only set that mirrors the content of the specified set.
36 * @param set the set to decorate.
38 public ReadOnlyBidirSortedSet (BidirSortedSet<G> set) {
45 public Gee.BidirIterator<G> bidir_iterator () {
46 return new BidirIterator<G> ((_collection as BidirSortedSet<G>).bidir_iterator ());
49 protected class BidirIterator<G> : Gee.ReadOnlyCollection.Iterator<G>, Gee.BidirIterator<G> {
50 public BidirIterator (Gee.BidirIterator<G> iterator) {
54 public bool first () {
55 return (_iter as Gee.BidirIterator<G>).first ();
58 public bool previous () {
59 return (_iter as Gee.BidirIterator<G>).previous ();
62 public bool has_previous () {
63 return (_iter as Gee.BidirIterator<G>).has_previous ();
67 return (_iter as Gee.BidirIterator<G>).last ();