Skip to content

Commit 9aba30a

Browse files
committed
slightly rewrite iterator
1 parent 277e840 commit 9aba30a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/iterator.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
struct GBIterator{O}
22
p::Ref{LibGraphBLAS.GxB_Iterator}
3+
A::AbstractGBArray
4+
function GBIterator(A::AbstractGBArray)
5+
#garbaage collection
6+
i = Ref{LibGraphBLAS.GxB_Iterator}()
7+
@wraperror LibGraphBLAS.GxB_Iterator_new(i)
8+
p = finalizer(iter) do ref
9+
@wraperror LibGraphBLAS.GxB_Iterator_free(ref)
10+
end
11+
return new{storageorder(A)}(p, A)
12+
end
313
end
414
gbpointer(I::GBIterator) = I.p[]
515

6-
function GBIterator(bycol=true) # this should be removed eventually. We always want an attached one.
7-
i = Ref{LibGraphBLAS.GxB_Iterator}()
8-
@wraperror LibGraphBLAS.GxB_Iterator_new(i)
9-
return GBIterator{}(finalizer(iter) do ref
10-
@wraperror LibGraphBLAS.GxB_Iterator_free(ref)
11-
end)
12-
end
13-
14-
function attach(I::GBIterator, A::AbstractGBArray; desc = nothing, itercolumns)
16+
function _attach(I::GBIterator{O}, A::AbstractGBArray; desc = nothing) where {O}
1517
desc = _handledescriptor(desc)
1618
@wraperror LibGraphBLAS.GxB_Iterator_attach(gbpointer(I), gbpointer(A), desc)
1719
end

0 commit comments

Comments
 (0)