Update Changelog
[profile/ivi/libgee.git] / gee / readonlybidirsortedmap.vala
1 /* readonlybidirsortedmap.vala
2  *
3  * Copyright (C) 2012  Maciej Piechotka
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18  *
19  * Author:
20  *      Maciej Piechotka <uzytkownik2@gmail.com>
21  */
22
23 /**
24  * Read-only view for {@link BidirSortedMap} collections.
25  *
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
28  * throw an error.
29  *
30  * @see BidirSortedMap
31  */
32 internal class Gee.ReadOnlyBidirSortedMap<K,V> : ReadOnlySortedMap<K,V>, BidirSortedMap<K,V> {
33         /**
34          * Constructs a read-only map that mirrors the content of the specified map.
35          *
36          * @param set the set to decorate.
37          */
38         public ReadOnlyBidirSortedMap (BidirSortedMap<K,V> map) {
39                 base (map);
40         }
41
42         /**
43          * {@inheritDoc}
44          */
45         public Gee.BidirMapIterator<K,V> bidir_map_iterator () {
46                 return new BidirMapIterator<K,V> ((_map as BidirSortedMap<K,V>).bidir_map_iterator ());
47         }
48
49         protected class BidirMapIterator<K,V> : Gee.ReadOnlyMap.MapIterator<K,V>, Gee.BidirMapIterator<K,V> {
50                 public BidirMapIterator (Gee.BidirMapIterator<K,V> iterator) {
51                         base (iterator);
52                 }
53
54                 public bool first () {
55                         return (_iter as Gee.BidirMapIterator<K,V>).first ();
56                 }
57
58                 public bool previous () {
59                         return (_iter as Gee.BidirMapIterator<K,V>).previous ();
60                 }
61
62                 public bool has_previous () {
63                         return (_iter as Gee.BidirMapIterator<K,V>).has_previous ();
64                 }
65
66                 public bool last () {
67                         return (_iter as Gee.BidirMapIterator<K,V>).last ();
68                 }
69         }
70 }
71