Skip to content

Commit 1440976

Browse files
committed
Add a few examples to README
1 parent de1b042 commit 1440976

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,35 @@
44
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaSIMD.github.io/ManualMemory.jl/dev)
55
[![Build Status](https://github.com/JuliaSIMD/ManualMemory.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/JuliaSIMD/ManualMemory.jl/actions/workflows/CI.yml)
66
[![Coverage](https://codecov.io/gh/JuliaSIMD/ManualMemory.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaSIMD/ManualMemory.jl)
7+
8+
Manually managed memory buffers backed by NTuples
9+
10+
### Examples
11+
12+
```julia
13+
julia> using ManualMemory: MemoryBuffer, load, store!, LazyPreserve, preserve, PseudoPtr, Reference
14+
15+
julia> m = MemoryBuffer{4,Float64}(undef)
16+
MemoryBuffer{4, Float64}((2.283825594e-314, 2.2157350003e-314, 2.216358792e-314, 2.08e-322))
17+
18+
julia> store!(pointer(m), 1.23)
19+
20+
julia> load(pointer(m))
21+
1.23
22+
```
23+
Specifying an existing `NTuple` of data:
24+
```julia
25+
julia> s = (1,2,3,4,5);
26+
27+
julia> m = MemoryBuffer(s)
28+
MemoryBuffer{5, Int64}((1, 2, 3, 4, 5))
29+
30+
julia> load(p)
31+
1
32+
33+
julia> load(p+sizeof(Int64))
34+
2
35+
36+
julia> load(p+sizeof(Int64)*2)
37+
3
38+
```

0 commit comments

Comments
 (0)