3 * Copyright (C) 2007-2008 Jürg Billeter
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 * Jürg Billeter <j@bitron.ch>
26 * Read-only view for {@link List} collections.
28 * This class decorates any class which implements the {@link List}
29 * interface by making it read only. Any method which normally modify data will
34 internal class Gee.ReadOnlyList<G> : Gee.ReadOnlyCollection<G>, List<G> {
37 * Constructs a read-only list that mirrors the content of the specified
40 * @param list the list to decorate.
42 public ReadOnlyList (List<G> list) {
49 public ListIterator<G> list_iterator () {
50 return new Iterator<G> (((Gee.List<G>) _collection).list_iterator ());
56 public int index_of (G item) {
57 return ((Gee.List<G>) _collection).index_of (item);
61 * Unimplemented method (read only list).
63 public void insert (int index, G item) {
64 assert_not_reached ();
68 * Unimplemented method (read only list).
70 public G remove_at (int index) {
71 assert_not_reached ();
77 public new G? get (int index) {
78 return ((Gee.List<G>) _collection).get (index);
82 * Unimplemented method (read only list).
84 public new void set (int index, G o) {
85 assert_not_reached ();
91 public List<G>? slice (int start, int stop) {
92 return ((Gee.List<G>) _collection).slice (start, stop);
99 return ((Gee.List<G>) _collection).first ();
106 return ((Gee.List<G>) _collection).last ();
110 * Unimplemented method (read only list).
112 public void insert_all (int index, Collection<G> collection) {
113 assert_not_reached ();
119 public void sort (owned CompareDataFunc<G>? compare = null) {
120 assert_not_reached ();
126 public virtual new List<G> read_only_view {
127 owned get { return this; }
131 protected class Iterator<G> : ReadOnlyCollection.Iterator<G>, ListIterator<G> {
132 public Iterator (ListIterator<G> iterator) {
136 public new void set (G item) {
137 assert_not_reached ();
140 public void add (G item) {
141 assert_not_reached ();
144 public int index () {
145 return ((ListIterator<G>) _iter).index ();