diff options
author | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-15 19:29:08 -0800 |
---|---|---|
committer | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-15 19:29:08 -0800 |
commit | 43a7081665d3b3754dd26f2b2cc8d0125ee74065 (patch) | |
tree | cff9c4630aa12aa7b0bc0d68ac0d7e69b0ff2dd5 /core | |
parent | f26d06d8b3dafae8b849bb0b812f2ce58df92423 (diff) | |
download | go-git-43a7081665d3b3754dd26f2b2cc8d0125ee74065.tar.gz |
Renamed ObjectStorage.IterType() to Iter() and improved documentation for object iterators
Diffstat (limited to 'core')
-rw-r--r-- | core/object.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/object.go b/core/object.go index 2c41245..9b6e56d 100644 --- a/core/object.go +++ b/core/object.go @@ -21,7 +21,7 @@ type ObjectStorage interface { New() Object Set(Object) Hash Get(Hash) (Object, bool) - IterType(ObjectType) ObjectIter + Iter(ObjectType) ObjectIter } // ObjectType internal object type's @@ -59,8 +59,13 @@ type ObjectIter interface { Close() } -// ObjectLookupIter yields a series of objects by retrieving each one from -// object storage. +// ObjectLookupIter implements ObjectIter. It iterates over a series of object +// hashes and yields their associated objects by retrieving each one from +// object storage. The retrievals are lazy and only occur when the iterator +// moves forward with a call to Next(). +// +// The ObjectLookupIter must be closed with a call to Close() when it is no +// longer needed. type ObjectLookupIter struct { storage ObjectStorage series []Hash @@ -99,7 +104,11 @@ func (iter *ObjectLookupIter) Close() { iter.pos = len(iter.series) } -// ObjectSliceIter yields a series of objects from a slice of objects. +// ObjectSliceIter implements ObjectIter. It iterates over a series of objects +// stored in a slice and yields each one in turn when Next() is called. +// +// The ObjectSliceIter must be closed with a call to Close() when it is no +// longer needed. type ObjectSliceIter struct { series []Object pos int @@ -189,7 +198,7 @@ func (o *RAWObjectStorage) Get(h Hash) (Object, bool) { return obj, ok } -func (o *RAWObjectStorage) IterType(t ObjectType) ObjectIter { +func (o *RAWObjectStorage) Iter(t ObjectType) ObjectIter { var series []Object switch t { case CommitObject: |