/* readonlybidirsortedset.vala * * Copyright (C) 2012 Maciej Piechotka * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Author: * Maciej Piechotka */ /** * Read-only view for {@link BidirSortedSet} collections. * * This class decorates any class which implements the {@link BidirSortedSet} * interface by making it read only. Any method which normally modify data will * throw an error. * * @see BidirSortedSet */ internal class Gee.ReadOnlyBidirSortedSet : ReadOnlySortedSet, BidirSortedSet { /** * Constructs a read-only set that mirrors the content of the specified set. * * @param set the set to decorate. */ public ReadOnlyBidirSortedSet (BidirSortedSet set) { base (set); } /** * {@inheritDoc} */ public Gee.BidirIterator bidir_iterator () { return new BidirIterator ((_collection as BidirSortedSet).bidir_iterator ()); } protected class BidirIterator : Gee.ReadOnlyCollection.Iterator, Gee.BidirIterator { public BidirIterator (Gee.BidirIterator iterator) { base (iterator); } public bool first () { return (_iter as Gee.BidirIterator).first (); } public bool previous () { return (_iter as Gee.BidirIterator).previous (); } public bool has_previous () { return (_iter as Gee.BidirIterator).has_previous (); } public bool last () { return (_iter as Gee.BidirIterator).last (); } } }