diff options
Diffstat (limited to 'gee/queue.vala')
-rw-r--r-- | gee/queue.vala | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gee/queue.vala b/gee/queue.vala index 787f80a..3658e67 100644 --- a/gee/queue.vala +++ b/gee/queue.vala @@ -43,6 +43,7 @@ * inserted into a Queue, as ``null`` is also used as a special return value by * the poll method to indicate that the queue contains no elements. */ +[GenericAccessors] public interface Gee.Queue<G> : Collection<G> { /** @@ -73,7 +74,9 @@ public interface Gee.Queue<G> : Collection<G> { * * @return ``true`` if the element was added to the queue */ - public abstract bool offer (G element); + public virtual bool offer (G element) { + return add (element); + } /** * Peeks (retrieves, but not remove) an element from this queue. @@ -100,5 +103,13 @@ public interface Gee.Queue<G> : Collection<G> { * * @return the amount of elements that were actually drained */ - public abstract int drain (Collection<G> recipient, int amount = -1); + public virtual int drain (Collection<G> recipient, int amount = -1) { + G? item = null; + int drained = 0; + while((amount == -1 || --amount >= 0) && (item = poll ()) != null) { + recipient.add (item); + drained++; + } + return drained; + } } |