MCPcopy Index your code
hub / github.com/clojure/clojure / iter

Method iter

src/jvm/clojure/lang/RT.java:591–634  ·  view source on GitHub ↗
(Object coll)

Source from the content-addressed store, hash-verified

589}
590
591static public Iterator iter(Object coll){
592 if(coll instanceof Iterable)
593 return ((Iterable)coll).iterator();
594 else if(coll == null)
595 return new Iterator(){
596 public boolean hasNext(){
597 return false;
598 }
599
600 public Object next(){
601 throw new NoSuchElementException();
602 }
603
604 public void remove(){
605 throw new UnsupportedOperationException();
606 }
607 };
608 else if(coll instanceof Map){
609 return ((Map)coll).entrySet().iterator();
610 }
611 else if(coll instanceof String){
612 final String s = (String) coll;
613 return new Iterator(){
614 int i = 0;
615
616 public boolean hasNext(){
617 return i < s.length();
618 }
619
620 public Object next(){
621 return s.charAt(i++);
622 }
623
624 public void remove(){
625 throw new UnsupportedOperationException();
626 }
627 };
628 }
629 else if(coll.getClass().isArray()){
630 return ArrayIter.createFromObject(coll);
631 }
632 else
633 return iter(seq(coll));
634}
635
636static public Object seqOrElse(Object o) {
637 return seq(o) == null ? null : o;

Callers

nothing calls this directly

Calls 4

createFromObjectMethod · 0.95
seqMethod · 0.95
iteratorMethod · 0.65
entrySetMethod · 0.45

Tested by

no test coverage detected