Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit d1bc264d67190ce7ac3cfde1d1e95871e291e214 1 parent b5b3a62
Travis Wellman authored

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 1 src/jvm/backtype/storm/tuple/Tuple.java
6 src/jvm/backtype/storm/tuple/Tuple.java
@@ -302,6 +302,7 @@ public ISeq seq() {
302 302 Seq(List<String> fields, List<Object> values, int i) {
303 303 this.fields = fields;
304 304 this.values = values;
  305 + assert i >= 0;
305 306 this.i = i;
306 307 }
307 308
@@ -309,6 +310,7 @@ public Seq(IPersistentMap meta, List<String> fields, List<Object> values, int i)
309 310 super(meta);
310 311 this.fields= fields;
311 312 this.values = values;
  313 + assert i >= 0;
312 314 this.i = i;
313 315 }
314 316
@@ -324,7 +326,9 @@ public ISeq next() {
324 326 }
325 327
326 328 public int count() {
327   - return fields.size();
  329 + assert fields.size() -i >= 0 : "index out of bounds";
  330 + // i being the position in the fields of this seq, the remainder of the seq is the size
  331 + return fields.size() -i;
328 332 }
329 333
330 334 public Obj withMeta(IPersistentMap meta) {

0 comments on commit d1bc264

Please sign in to comment.
Something went wrong with that request. Please try again.