[libgee] Use non-nullable capacities and a constant to specify unbounded
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Use non-nullable capacities and a constant to specify unbounded
- Date: Mon, 14 Sep 2009 17:16:32 +0000 (UTC)
commit 9f3357676f93569deef4eec486f942e462df5da2
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Mon Sep 14 18:34:09 2009 +0200
Use non-nullable capacities and a constant to specify unbounded
gee/linkedlist.vala | 8 ++++----
gee/queue.vala | 12 +++++++++---
tests/testqueue.vala | 4 ++--
3 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala
index 7b4775f..802a278 100644
--- a/gee/linkedlist.vala
+++ b/gee/linkedlist.vala
@@ -246,15 +246,15 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
/**
* @inheritDoc
*/
- public int? capacity {
- get { return null; }
+ public int capacity {
+ get { return UNBOUNDED_CAPACITY; }
}
/**
* @inheritDoc
*/
- public int? remaining_capacity {
- get { return null; }
+ public int remaining_capacity {
+ get { return UNBOUNDED_CAPACITY; }
}
/**
diff --git a/gee/queue.vala b/gee/queue.vala
index 321479b..cc67e56 100644
--- a/gee/queue.vala
+++ b/gee/queue.vala
@@ -26,7 +26,7 @@
* Although all Queue implementations do not limit the amount of elements they
* can contain, this interface supports for capacity-bounded queues. When
* capacity is not bound, then the { link capacity} and
- * { link remaining_capacity} both return null.
+ * { link remaining_capacity} both return { link UNBOUNDED_CAPACITY}.
*
* This interface defines methods that will never fail whatever the state of
* the queue is. For capacity-bounded queues, those methods will either return
@@ -44,15 +44,21 @@
* poll method to indicate that the queue contains no elements.
*/
public interface Gee.Queue<G> : Collection<G> {
+
+ /**
+ * The unbounded capacity value.
+ */
+ public static const int UNBOUNDED_CAPACITY = -1;
+
/**
* The capacity of this queue (or null if capacity is not bound).
*/
- public abstract int? capacity { get; }
+ public abstract int capacity { get; }
/**
* The remaining capacity of this queue (or null if capacity is not bound).
*/
- public abstract int? remaining_capacity { get; }
+ public abstract int remaining_capacity { get; }
/**
* Specifies whether this queue is full.
diff --git a/tests/testqueue.vala b/tests/testqueue.vala
index e872084..86833ae 100644
--- a/tests/testqueue.vala
+++ b/tests/testqueue.vala
@@ -36,9 +36,9 @@ public abstract class QueueTests : CollectionTests {
// Check the test queue is not null
assert (test_queue != null);
- if (test_queue.capacity == null) {
+ if (test_queue.capacity == Gee.Queue.UNBOUNDED_CAPACITY) {
// Unbounded capacity
- assert (test_queue.remaining_capacity == null);
+ assert (test_queue.remaining_capacity == Gee.Queue.UNBOUNDED_CAPACITY);
assert (! test_queue.is_full);
} else {
// Bounded capacity
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]