-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the StdDequeIterator and its testset #433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,27 +126,41 @@ Base.size(v::StdValArray) = (Int(cppsize(v)),) | |
Base.getindex(v::StdValArray, i::Int) = cxxgetindex(v,i)[] | ||
Base.setindex!(v::StdValArray{T}, val, i::Int) where {T} = cxxsetindex!(v, convert(T,val), i) | ||
|
||
|
||
# Deque | ||
function StdDeque() where {T} | ||
return StdDeque{T}() | ||
end | ||
|
||
Base.IndexStyle(::Type{<:StdDeque}) = IndexLinear() | ||
Base.size(d::StdDeque) = (Int(cppsize(d)),) | ||
Base.resize!(d::StdDeque, n::Integer) = resize(d, n) | ||
Base.getindex(d::StdDeque, i::Int) = cxxgetindex(d, i)[] | ||
Base.setindex!(d::StdDeque{T}, val, i::Int) where {T} = cxxsetindex(d, convert(T, val), i) | ||
#TODO: edit the cxx part to enable push to get more than two arguments | ||
Base.getindex(d::StdDeque, i::Int) = cxxgetindex(d,i)[] | ||
Base.setindex!(d::StdDeque{T}, val, i::Int) where {T} = cxxsetindex(d, convert(T,val), i) | ||
Base.push!(d::StdDeque, x) = push_back(d, x) | ||
Base.pushfirst!(d::StdDeque, x) = push_front(d, x) | ||
Base.pop!(d::StdDeque) = pop_back(d) | ||
Base.popfirst!(d::StdDeque) = pop_front(d) | ||
Base.isempty(d::StdDeque) = isEmpty(d) | ||
Base.resize!(d::StdDeque, n::Integer) = resize(d, n) | ||
Base.empty!(d::StdDeque) = clear(d) | ||
|
||
# Iteration utilities | ||
Base.:(==)(a::StdIterator, b::StdIterator) = iterator_is_equal(a, b) | ||
_deque_iteration_tuple(d::StdDeque, state::StdIterator) = (state == iteratorend(d)) ? nothing : (iterator_value(state), state) | ||
Base.iterate(d::StdDeque) = _deque_iteration_tuple(d, iteratorbegin(d)) | ||
Base.iterate(d::StdDeque, state::StdIterator) = (state != iteratorend(d)) ? _deque_iteration_tuple(d, iterator_next(state)) : nothing | ||
#TODO:remove the iterator_value method from the cxx part, since it is not needed | ||
end # module | ||
Base.:(==)(a::StdDequeIterator, b::StdDequeIterator) = iterator_is_equal(a,b) | ||
function _iteration_tuple(d::StdDeque, state::StdDequeIterator) | ||
if state == iteratorend(d) return nothing end | ||
return (iterator_value(state), state) | ||
end | ||
Base.iterate(d::StdDeque) = _iteration_tuple(d, iteratorbegin(d)) | ||
Base.iterate(d::StdDeque, state::StdDequeIterator) = _iteration_tuple(d, iterator_next(state)) | ||
|
||
|
||
|
||
# Queue | ||
Base.size(v::StdQueue) = (Int(cppsize(v)),) | ||
Base.push!(v::StdQueue, x) = push_back(v, x) | ||
Base.first(v::StdQueue) = front(v) | ||
Base.pop!(v::StdQueue) = pop_front(v) | ||
Comment on lines
+156
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code seems to be unrelated to StdDeque? Perhaps this PR needs to be rebased on the latest CxxWrap master? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't handle this nicely in one commit and keep this out of the changes as the testjll-stditerator branch itself is far behind the master. |
||
|
||
function Base.fill!(v::T, x) where T <: Union{StdVector, StdValArray, StdDeque} | ||
StdFill(v, x) | ||
return v | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests fail because
StdDequeIterator
is not defined.Perhaps this PR is supposed to be used together with a changed libcxxwrap-julia ? Perhaps with JuliaInterop/libcxxwrap-julia#133 ? (It would be a good idea to point out something like this in the PR description)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done