1 /* readonlybidirsortedmap.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 BidirSortedMap} collections.
26 * This class decorates any class which implements the {@link BidirSortedMap}
27 * interface by making it read only. Any method which normally modify data will
32 internal class Gee.ReadOnlyBidirSortedMap<K,V> : ReadOnlySortedMap<K,V>, BidirSortedMap<K,V> {
34 * Constructs a read-only map that mirrors the content of the specified map.
36 * @param set the set to decorate.
38 public ReadOnlyBidirSortedMap (BidirSortedMap<K,V> map) {
45 public Gee.BidirMapIterator<K,V> bidir_map_iterator () {
46 return new BidirMapIterator<K,V> ((_map as BidirSortedMap<K,V>).bidir_map_iterator ());
49 protected class BidirMapIterator<K,V> : Gee.ReadOnlyMap.MapIterator<K,V>, Gee.BidirMapIterator<K,V> {
50 public BidirMapIterator (Gee.BidirMapIterator<K,V> iterator) {
54 public bool first () {
55 return (_iter as Gee.BidirMapIterator<K,V>).first ();
58 public bool previous () {
59 return (_iter as Gee.BidirMapIterator<K,V>).previous ();
62 public bool has_previous () {
63 return (_iter as Gee.BidirMapIterator<K,V>).has_previous ();
67 return (_iter as Gee.BidirMapIterator<K,V>).last ();