1 /* readonlybidirlist.vala
3 * Copyright (C) 2011 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>
23 internal class Gee.ReadOnlyBidirList<G> : Gee.ReadOnlyList<G>, BidirList<G> {
26 * Constructs a read-only list that mirrors the content of the specified
29 * @param list the list to decorate.
31 public ReadOnlyBidirList (BidirList<G> list) {
38 public BidirListIterator<G> bidir_list_iterator () {
39 return new Iterator<G> (((Gee.BidirList<G>) _collection).bidir_list_iterator ());
43 * The read-only view of this list.
45 public virtual new BidirList<G> read_only_view { owned get { return this; } }
47 private class Iterator<G> : ReadOnlyList.Iterator<G>, BidirIterator<G>, BidirListIterator<G> {
48 public Iterator (ListIterator<G> iterator) {
52 public bool previous () {
53 return ((BidirIterator<G>) _iter).previous ();
56 public bool has_previous () {
57 return ((BidirIterator<G>) _iter).has_previous ();
60 public bool first () {
61 return ((BidirIterator<G>) _iter).first ();
65 return ((BidirIterator<G>) _iter).last ();
68 public void insert (G item) {
69 assert_not_reached ();