Comments (6)
Here is what I did:
Add the following methods in src/CircularArrays.jl
.
Base.resize!(A::CircularVector, nl::Integer) = (resize!(parent(A), nl); A)
Base.push!(a::CircularVector, x...) = (push!(parent(a), x...); a)
Base.pop!(a::CircularVector) = pop!(parent(a))
Base.append!(a::CircularVector, items) = (append!(parent(a), items); a)
Base.empty!(a::CircularVector) = (empty!(parent(a)); a)
Now we have
julia> using CircularArrays
julia> c = CircularVector([1,2,3])
3-element CircularVector(::Vector{Int64}):
1
2
3
julia> push!(c, 4)
4-element CircularVector(::Vector{Int64}):
1
2
3
4
julia> c
4-element CircularVector(::Vector{Int64}):
1
2
3
4
julia> push!(c, 6,7,8)
7-element CircularVector(::Vector{Int64}):
1
2
3
4
6
7
8
from circulararrays.jl.
Thank you @terasakisatoshi!
@Vexatos is this a valid approach to be merged as a PR?
from circulararrays.jl.
Since I already have deleteat!
and insert!
as mutating methods, these should probably exist as well.
from circulararrays.jl.
@terasakisatoshi it would be nice to convert your comment to a PR 💯
from circulararrays.jl.
I found that when Base.resize!(A::CircularVector, nl::Integer) = (resize!(parent(A), nl); A)
is defined, we can use push!
.
from circulararrays.jl.
This is now available in Version 1.4.0.
from circulararrays.jl.
Related Issues (13)
- Type piracy with OffsetArrays HOT 1
- TagBot trigger issue HOT 8
- Implement deleteat! HOT 1
- Consider moving the package to JuliaArrays for greater visibility HOT 7
- map problem HOT 2
- Type consistency HOT 3
- Semantic versioning HOT 5
- No constructor for fully specified type HOT 1
- Fix Vararg warning HOT 1
- Missing `insert!` method HOT 1
- Wrong fallback for Base.empty
- Arrays that are circular in certain dimensions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circulararrays.jl.