Update Changelog
[profile/ivi/libgee.git] / gee / abstractsortedset.vala
1 /* abstractsortedset.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  * Skeletal implementation of the {@link SortedSet} interface.
25  *
26  * Contains common code shared by all set implementations.
27  *
28  * @see TreeSet
29  */
30 public abstract class Gee.AbstractSortedSet<G> : Gee.AbstractSet<G>, SortedSet<G> {
31         /**
32          * {@inheritDoc}
33          */
34         public abstract G first ();
35
36         /**
37          * {@inheritDoc}
38          */
39         public abstract G last ();
40
41         /**
42          * {@inheritDoc}
43          */
44         public abstract Iterator<G>? iterator_at (G element);
45
46         /**
47          * {@inheritDoc}
48          */
49         public abstract G? lower (G element);
50
51         /**
52          * {@inheritDoc}
53          */
54         public abstract G? higher (G element);
55
56         /**
57          * {@inheritDoc}
58          */
59         public abstract G? floor (G element);
60
61         /**
62          * {@inheritDoc}
63          */
64         public abstract G? ceil (G element);
65
66         /**
67          * {@inheritDoc}
68          */
69         public abstract SortedSet<G> head_set (G before);
70
71         /**
72          * {@inheritDoc}
73          */
74         public abstract SortedSet<G> tail_set (G after);
75
76         /**
77          * {@inheritDoc}
78          */
79         public abstract SortedSet<G> sub_set (G from, G to);
80
81         private weak SortedSet<G> _read_only_view;
82
83         /**
84          * {@inheritDoc}
85          */
86         public virtual new SortedSet<G> read_only_view {
87                 owned get {
88                         SortedSet<G> instance = _read_only_view;
89                         if (_read_only_view == null) {
90                                 instance = new ReadOnlySortedSet<G> (this);
91                                 _read_only_view = instance;
92                                 instance.add_weak_pointer ((void**) (&_read_only_view));
93                         }
94                         return instance;
95                 }
96         }
97
98         // Future-proofing
99         internal new virtual void reserved0() {}
100         internal new virtual void reserved1() {}
101         internal new virtual void reserved2() {}
102         internal new virtual void reserved3() {}
103         internal new virtual void reserved4() {}
104         internal new virtual void reserved5() {}
105         internal new virtual void reserved6() {}
106         internal new virtual void reserved7() {}
107         internal new virtual void reserved8() {}
108         internal new virtual void reserved9() {}
109 }
110