This page presents an idea about the development of libgee.

Proposed new Map interface:

public interface Gee.Map<K,V> : Object, Gee.Iterable<Entry<K,V>>, Gee.Collection<Entry<K,V>> {

        // From Iterable interface
        public abstract Type get_element_type ();
        public abstract Iterator<Entry<K,V>> iterator ();

        // From Collection interface
        public abstract int size { get; }                   // number of entries
        public abstract bool contains (Entry<K,V> item);    // returns true if the given entry exists; if there is the key, but with different value, it returns false
        public abstract bool add (Entry<K,V> item);         // fails if the key exists
        public abstract bool remove (Entry<K,V> item);      // fails if the key-value combination doesn't exits
        public abstract void clear ();

        // Specific for Map
        public abstract Set<K> get_keys ();
        public abstract Collection<V> get_values ();

        public abstract bool contains_key (K key);
        public abstract bool contains_value (V? value);

        public abstract V? get (K key);
        public abstract void set (K key, V? value);
        public abstract bool unset (K key, out V? value = null);

        public abstract bool replace (K key, ref V value);        // exchanges value of passed variable with the value of given key; returns true if the key was present
                                                                  // if there is no such key, behaves like set() and passed variable is set to null

Projects/Libgee/NewMapInterfaceProposal (last edited 2013-11-22 18:14:18 by WilliamJonMcCann)