1 /* abstractcollection.vala
3 * Copyright (C) 2007 Jürg Billeter
4 * Copyright (C) 2009 Didier Villevalois
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Didier 'Ptitjes' Villevalois <ptitjes@free.fr>
25 * Skeletal implementation of the {@link Collection} interface.
27 * Contains common code shared by all collection implementations.
31 * @see AbstractMultiSet
33 public abstract class Gee.AbstractCollection<G> : Object, Traversable<G>, Iterable<G>, Collection<G> {
37 public abstract int size { get; }
42 public abstract bool read_only { get; }
47 public abstract bool contains (G item);
52 public abstract bool add (G item);
57 public abstract bool remove (G item);
62 public abstract void clear ();
67 public abstract Iterator<G> iterator ();
69 public virtual bool foreach (ForallFunc<G> f) {
70 return iterator ().foreach (f);
73 private weak Collection<G> _read_only_view;
78 public virtual Collection<G> read_only_view {
80 Collection<G> instance = _read_only_view;
81 if (_read_only_view == null) {
82 instance = new ReadOnlyCollection<G> (this);
83 _read_only_view = instance;
84 instance.add_weak_pointer ((void**) (&_read_only_view));
91 internal virtual void reserved0() {}
92 internal virtual void reserved1() {}
93 internal virtual void reserved2() {}
94 internal virtual void reserved3() {}
95 internal virtual void reserved4() {}
96 internal virtual void reserved5() {}
97 internal virtual void reserved6() {}
98 internal virtual void reserved7() {}
99 internal virtual void reserved8() {}
100 internal virtual void reserved9() {}