Update Changelog
[profile/ivi/libgee.git] / gee / readonlysortedmap.vala
1 /* readonlysortedmap.vala
2  *
3  * Copyright (C) 2009-2011  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 SortedMap} collections.
25  *
26  * This class decorates any class which implements the {@link SortedMap} interface
27  * by making it read only. Any method which normally modify data will throw an
28  * error.
29  *
30  * @see SortedMap
31  */
32 internal class Gee.ReadOnlySortedMap<K,V> : ReadOnlyMap<K,V>, SortedMap<K,V> {
33         /**
34          * Constructs a read-only map that mirrors the content of the specified map.
35          *
36          * @param map the map to decorate.
37          */
38         public ReadOnlySortedMap (Map<K,V> map) {
39                 base (map);
40         }
41
42         /**
43          * {@inheritDoc}
44          */
45         public SortedMap<K,V> head_map (K before) {
46                 return (_map as SortedMap<K,V>).head_map (before).read_only_view;
47         }
48
49         /**
50          * {@inheritDoc}
51          */
52         public SortedMap<K,V> tail_map (K after) {
53                 return (_map as SortedMap<K,V>).tail_map (after).read_only_view;
54         }
55
56         /**
57          * {@inheritDoc}
58          */
59         public SortedMap<K,V> sub_map (K from, K to) {
60                 return (_map as SortedMap<K,V>).sub_map (from, to).read_only_view;
61         }
62
63         /**
64          * {@inheritDoc}
65          */
66         public SortedSet<K> ascending_keys {
67                 owned get {
68                         return (_map as SortedMap<K,V>).ascending_keys.read_only_view;
69                 }
70         }
71
72         /**
73          * {@inheritDoc}
74          */
75         public SortedSet<Map.Entry<K,V>> ascending_entries {
76                 owned get {
77                         return (_map as SortedMap<K,V>).ascending_entries.read_only_view;
78                 }
79         }
80 }
81