libgee_la_VALASOURCES = \
arraylist.vala \
collection.vala \
- collectionobject.vala \
hashmap.vala \
hashset.vala \
iterable.vala \
/**
* Arrays of arbitrary elements which grow automatically as elements are added.
*/
-public class Vala.ArrayList<G> : CollectionObject, Iterable<G>, Collection<G>, List<G> {
- public int size {
+public class Vala.ArrayList<G> : List<G> {
+ public override int size {
get { return _size; }
}
this.equal_func = equal_func;
}
- public Type get_element_type () {
+ public override Type get_element_type () {
return typeof (G);
}
- public Vala.Iterator<G> iterator () {
+ public override Vala.Iterator<G> iterator () {
return new Iterator<G> (this);
}
- public bool contains (G item) {
+ public override bool contains (G item) {
return (index_of (item) != -1);
}
- public int index_of (G item) {
+ public override int index_of (G item) {
for (int index = 0; index < _size; index++) {
if (_equal_func (_items[index], item)) {
return index;
return -1;
}
- public G? get (int index) {
+ public override G? get (int index) {
assert (index >= 0 && index < _size);
return _items[index];
}
- public void set (int index, G item) {
+ public override void set (int index, G item) {
assert (index >= 0 && index < _size);
_items[index] = item;
}
- public bool add (G item) {
+ public override bool add (G item) {
if (_size == _items.length) {
grow_if_needed (1);
}
return true;
}
- public void insert (int index, G item) {
+ public override void insert (int index, G item) {
assert (index >= 0 && index <= _size);
if (_size == _items.length) {
_stamp++;
}
- public bool remove (G item) {
+ public override bool remove (G item) {
for (int index = 0; index < _size; index++) {
if (_equal_func (_items[index], item)) {
remove_at (index);
return false;
}
- public void remove_at (int index) {
+ public override void remove_at (int index) {
assert (index >= 0 && index < _size);
_items[index] = null;
_stamp++;
}
- public void clear () {
+ public override void clear () {
for (int index = 0; index < _size; index++) {
_items[index] = null;
}
_items.resize (value);
}
- private class Iterator<G> : CollectionObject, Vala.Iterator<G> {
+ private class Iterator<G> : Vala.Iterator<G> {
public ArrayList<G> list {
set {
_list = value;
this.list = list;
}
- public bool next () {
+ public override bool next () {
assert (_stamp == _list._stamp);
if (_index < _list._size) {
_index++;
return (_index < _list._size);
}
- public G? get () {
+ public override G? get () {
assert (_stamp == _list._stamp);
if (_index < 0 || _index >= _list._size) {
* Serves as the base interface for implementing collection classes. Defines
* size, iteration, and modification methods.
*/
-public interface Vala.Collection<G> : Iterable<G> {
+public abstract class Vala.Collection<G> : Iterable<G> {
/**
* The number of items in this collection.
*/
+++ /dev/null
-/* collectionobject.vala
- *
- * Copyright (C) 2008 Jürg Billeter
- *
- * 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:
- * Jürg Billeter <j@bitron.ch>
- */
-
-using GLib;
-
-/**
- * Base class for all collections.
- */
-public class Vala.CollectionObject {
-}
-
/**
* Hashtable implementation of the Map interface.
*/
-public class Vala.HashMap<K,V> : CollectionObject, Map<K,V> {
- public int size {
+public class Vala.HashMap<K,V> : Map<K,V> {
+ public override int size {
get { return _nnodes; }
}
_nodes = new Node<K,V>[_array_size];
}
- public Set<K> get_keys () {
+ public override Set<K> get_keys () {
return new KeySet<K,V> (this);
}
- public Collection<V> get_values () {
+ public override Collection<V> get_values () {
return new ValueCollection<K,V> (this);
}
return node;
}
- public bool contains (K key) {
+ public override bool contains (K key) {
Node<K,V>** node = lookup_node (key);
return (*node != null);
}
- public V? get (K key) {
+ public override V? get (K key) {
Node<K,V>* node = (*lookup_node (key));
if (node != null) {
return node->value;
}
}
- public void set (K key, V value) {
+ public override void set (K key, V value) {
Node<K,V>** node = lookup_node (key);
if (*node != null) {
(*node)->value = value;
_stamp++;
}
- public bool remove (K key) {
+ public override bool remove (K key) {
Node<K,V>** node = lookup_node (key);
if (*node != null) {
Node<K,V> next = (owned) (*node)->next;
return false;
}
- public void clear () {
+ public override void clear () {
for (int i = 0; i < _array_size; i++) {
Node<K,V> node = (owned) _nodes[i];
while (node != null) {
}
}
- private class KeySet<K,V> : CollectionObject, Iterable<K>, Collection<K>, Set<K> {
+ private class KeySet<K,V> : Set<K> {
public HashMap<K,V> map {
set { _map = value; }
}
this.map = map;
}
- public Type get_element_type () {
+ public override Type get_element_type () {
return typeof (K);
}
- public Iterator<K> iterator () {
+ public override Iterator<K> iterator () {
return new KeyIterator<K,V> (_map);
}
- public int size {
+ public override int size {
get { return _map.size; }
}
- public bool add (K key) {
+ public override bool add (K key) {
assert_not_reached ();
}
- public void clear () {
+ public override void clear () {
assert_not_reached ();
}
- public bool remove (K key) {
+ public override bool remove (K key) {
assert_not_reached ();
}
- public bool contains (K key) {
+ public override bool contains (K key) {
return _map.contains (key);
}
}
- private class KeyIterator<K,V> : CollectionObject, Iterator<K> {
+ private class KeyIterator<K,V> : Iterator<K> {
public HashMap<K,V> map {
set {
_map = value;
this.map = map;
}
- public bool next () {
+ public override bool next () {
if (_node != null) {
_node = _node.next;
}
return (_node != null);
}
- public K? get () {
+ public override K? get () {
assert (_stamp == _map._stamp);
assert (_node != null);
return _node.key;
}
}
- private class ValueCollection<K,V> : CollectionObject, Iterable<V>, Collection<V> {
+ private class ValueCollection<K,V> : Collection<V> {
public HashMap<K,V> map {
set { _map = value; }
}
this.map = map;
}
- public Type get_element_type () {
+ public override Type get_element_type () {
return typeof (V);
}
- public Iterator<V> iterator () {
+ public override Iterator<V> iterator () {
return new ValueIterator<K,V> (_map);
}
- public int size {
+ public override int size {
get { return _map.size; }
}
- public bool add (V value) {
+ public override bool add (V value) {
assert_not_reached ();
}
- public void clear () {
+ public override void clear () {
assert_not_reached ();
}
- public bool remove (V value) {
+ public override bool remove (V value) {
assert_not_reached ();
}
- public bool contains (V value) {
+ public override bool contains (V value) {
Iterator<V> it = iterator ();
while (it.next ()) {
if (_map._value_equal_func (it.get (), value)) {
}
}
- private class ValueIterator<K,V> : CollectionObject, Iterator<V> {
+ private class ValueIterator<K,V> : Iterator<V> {
public HashMap<K,V> map {
set {
_map = value;
this.map = map;
}
- public bool next () {
+ public override bool next () {
if (_node != null) {
_node = _node.next;
}
return (_node != null);
}
- public V? get () {
+ public override V? get () {
assert (_stamp == _map._stamp);
assert (_node != null);
return _node.value;
/**
* Hashtable implementation of the Set interface.
*/
-public class Vala.HashSet<G> : CollectionObject, Iterable<G>, Collection<G>, Set<G> {
- public int size {
+public class Vala.HashSet<G> : Set<G> {
+ public override int size {
get { return _nnodes; }
}
return node;
}
- public bool contains (G key) {
+ public override bool contains (G key) {
Node<G>** node = lookup_node (key);
return (*node != null);
}
- public Type get_element_type () {
+ public override Type get_element_type () {
return typeof (G);
}
- public Vala.Iterator<G> iterator () {
+ public override Vala.Iterator<G> iterator () {
return new Iterator<G> (this);
}
- public bool add (G key) {
+ public override bool add (G key) {
Node<G>** node = lookup_node (key);
if (*node != null) {
return false;
}
}
- public bool remove (G key) {
+ public override bool remove (G key) {
Node<G>** node = lookup_node (key);
if (*node != null) {
Node<G> next = (owned) (*node)->next;
return false;
}
- public void clear () {
+ public override void clear () {
for (int i = 0; i < _array_size; i++) {
Node<G> node = (owned) _nodes[i];
while (node != null) {
}
}
- private class Iterator<G> : CollectionObject, Vala.Iterator<G> {
+ private class Iterator<G> : Vala.Iterator<G> {
public HashSet<G> set {
set {
_set = value;
this.set = set;
}
- public bool next () {
+ public override bool next () {
if (_node != null) {
_node = _node.next;
}
return (_node != null);
}
- public G? get () {
+ public override G? get () {
assert (_stamp == _set._stamp);
assert (_node != null);
return _node.key;
* Implemented by classes that support a simple iteration over instances of the
* collection.
*/
-public interface Vala.Iterable<G> : CollectionObject {
+public abstract class Vala.Iterable<G> {
public abstract Type get_element_type ();
/**
* Implemented by classes that support a simple iteration over instances of the
* collection.
*/
-public interface Vala.Iterator<G> : CollectionObject {
+public abstract class Vala.Iterator<G> {
/**
* Advances to the next element in the iteration.
*
/**
* Represents a collection of items in a well-defined order.
*/
-public interface Vala.List<G> : Collection<G> {
+public abstract class Vala.List<G> : Collection<G> {
/**
* Returns the item at the specified index in this list.
*
/**
* A map is a generic collection of key/value pairs.
*/
-public interface Vala.Map<K,V> : CollectionObject {
+public abstract class Vala.Map<K,V> {
/**
* The number of items in this map.
*/
/**
* A set is a collection without duplicates.
*/
-public interface Vala.Set<G> : Collection<G> {
+public abstract class Vala.Set<G> : Collection<G> {
}