|
@@ -1,18 +1,14 @@
|
|
|
|
|
|
namespace Invercargill {
|
|
namespace Invercargill {
|
|
|
|
|
|
- // public interface Enumerable<T> {
|
|
|
|
-
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
public abstract class Enumerable<T> {
|
|
public abstract class Enumerable<T> {
|
|
|
|
|
|
- public abstract Tracker<T> to_tracker();
|
|
|
|
|
|
+ public abstract Tracker<T> get_tracker();
|
|
|
|
|
|
// Returns false if iteration was interrupted
|
|
// Returns false if iteration was interrupted
|
|
// Returns true if iteration reached natural end
|
|
// Returns true if iteration reached natural end
|
|
public virtual bool iterate_if(PredicateDelegate<T> handler) {
|
|
public virtual bool iterate_if(PredicateDelegate<T> handler) {
|
|
- var tracker = to_tracker();
|
|
|
|
|
|
+ var tracker = get_tracker();
|
|
while(tracker.has_next()) {
|
|
while(tracker.has_next()) {
|
|
if(!handler(tracker.get_next())) {
|
|
if(!handler(tracker.get_next())) {
|
|
return false;
|
|
return false;
|
|
@@ -34,12 +30,16 @@ namespace Invercargill {
|
|
return sequence;
|
|
return sequence;
|
|
}
|
|
}
|
|
|
|
|
|
- public virtual Gee.Collection to_collection() {
|
|
|
|
|
|
+ public virtual Gee.Collection<T> to_collection() {
|
|
var collection = new Gee.LinkedList<T>();
|
|
var collection = new Gee.LinkedList<T>();
|
|
iterate(i => collection.add(i));
|
|
iterate(i => collection.add(i));
|
|
return collection;
|
|
return collection;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public virtual Gee.Iterable<T> as_iterable() {
|
|
|
|
+ return new GeeIterable<T>(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
public virtual T[] to_array() {
|
|
public virtual T[] to_array() {
|
|
return to_collection().to_array();
|
|
return to_collection().to_array();
|
|
}
|
|
}
|