Permalink
Browse files

The count of a seq is 1 + the number of remaining seqs through next()

  • Loading branch information...
1 parent b5b3a62 commit d1bc264d67190ce7ac3cfde1d1e95871e291e214 Travis Wellman committed Mar 2, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/jvm/backtype/storm/tuple/Tuple.java
View
6 src/jvm/backtype/storm/tuple/Tuple.java
@@ -302,13 +302,15 @@ public ISeq seq() {
Seq(List<String> fields, List<Object> values, int i) {
this.fields = fields;
this.values = values;
+ assert i >= 0;
this.i = i;
}
public Seq(IPersistentMap meta, List<String> fields, List<Object> values, int i) {
super(meta);
this.fields= fields;
this.values = values;
+ assert i >= 0;
this.i = i;
}
@@ -324,7 +326,9 @@ public ISeq next() {
}
public int count() {
- return fields.size();
+ assert fields.size() -i >= 0 : "index out of bounds";
+ // i being the position in the fields of this seq, the remainder of the seq is the size
+ return fields.size() -i;
}
public Obj withMeta(IPersistentMap meta) {

0 comments on commit d1bc264

Please sign in to comment.