Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
figures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
poquet
millian
figures
Commits
44efaf2f
Commit
44efaf2f
authored
2 months ago
by
Millian Poquet
Browse files
Options
Downloads
Patches
Plain Diff
ring buffer
parent
a224feff
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ring-buffer/mpoquet.tmTheme
+374
-0
374 additions, 0 deletions
ring-buffer/mpoquet.tmTheme
ring-buffer/ring-buffer.pdf
+0
-0
0 additions, 0 deletions
ring-buffer/ring-buffer.pdf
ring-buffer/ring-buffer.typ
+109
-0
109 additions, 0 deletions
ring-buffer/ring-buffer.typ
with
483 additions
and
0 deletions
ring-buffer/mpoquet.tmTheme
0 → 100644
+
374
−
0
View file @
44efaf2f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
author
</key>
<string>
Ankur Gupta
</string>
<key>
name
</key>
<string>
GitHub Clean White
</string>
<key>
settings
</key>
<array>
<dict>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#FFFFFF
</string>
<key>
caret
</key>
<string>
#000000
</string>
<key>
foreground
</key>
<string>
#000000
</string>
<key>
invisibles
</key>
<string>
#B3B3B3F4
</string>
<key>
lineHighlight
</key>
<string>
#0000001A
</string>
<key>
selection
</key>
<string>
#BAD6FD
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
String
</string>
<key>
scope
</key>
<string>
string
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#C41A16
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Number
</string>
<key>
scope
</key>
<string>
constant.numeric
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#0086B3
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Keyword
</string>
<key>
scope
</key>
<string>
keyword
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#A71D5D
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Operator
</string>
<key>
scope
</key>
<string>
keyword.operator
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Built-in constant
</string>
<key>
scope
</key>
<string>
constant.language
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#0086B3
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Exception
</string>
<key>
scope
</key>
<string>
support.class.exception
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#990000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Function name
</string>
<key>
scope
</key>
<string>
entity.name.function
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#000000
</string>
<!-- <key>fontStyle</key>
<string>italic</string> -->
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Type name
</string>
<key>
scope
</key>
<string>
entity.name.type
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
bold underline
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Arguments
</string>
<key>
scope
</key>
<string>
variable.parameter
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
italic
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Comment
</string>
<key>
scope
</key>
<string>
comment
</string>
<key>
settings
</key>
<dict>
<!-- <key>fontStyle</key>
<string>italic</string> -->
<key>
foreground
</key>
<string>
#707070
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Invalid
</string>
<key>
scope
</key>
<string>
invalid
</string>
<key>
settings
</key>
<dict>
<!-- <key>background</key>
<string>#E71A114D</string> -->
<key>
foreground
</key>
<string>
#FF0000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Trailing whitespace
</string>
<key>
scope
</key>
<string>
invalid.deprecated.trailing-whitespace
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#E71A1100
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Embedded source
</string>
<key>
scope
</key>
<string>
text source
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#FAFAFAFC
</string>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Tag
</string>
<key>
scope
</key>
<string>
meta.tag, declaration.tag
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#AA0D91
</string>
</dict>
</dict>
<!-- <dict>
<key>name</key>
<string>Constant</string>
<key>scope</key>
<string>constant, support.constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#000000</string>
</dict>
</dict> -->
<dict>
<key>
name
</key>
<string>
Support
</string>
<key>
scope
</key>
<string>
support
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
bold
</string>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Storage
</string>
<key>
scope
</key>
<string>
storage
</string>
<key>
settings
</key>
<dict>
<!-- <key>fontStyle</key>
<string>bold</string> -->
<key>
foreground
</key>
<string>
#AA0D91
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Section name
</string>
<key>
scope
</key>
<string>
entity.name.section
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
bold underline
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
Frame title
</string>
<key>
scope
</key>
<string>
entity.name.function.frame
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
bold
</string>
<key>
foreground
</key>
<string>
#000000
</string>
<!-- <string>#881280</string> -->
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
XML Declaration
</string>
<key>
scope
</key>
<string>
meta.tag.preprocessor.xml
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#333333
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
html attribute
</string>
<key>
scope
</key>
<string>
entity.other.attribute-name
</string>
<key>
settings
</key>
<dict>
<key>
fontStyle
</key>
<string>
italic
</string>
<key>
foreground
</key>
<!-- <string>#3366CC</string> -->
<string>
#0A8585
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
html tag punctuation
</string>
<key>
scope
</key>
<string>
entity.name.tag
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#121289
</string>
<!-- <key>fontStyle</key>
<string>bold</string> -->
</dict>
</dict>
<!-- Adding stuff for diff. This works in ST3 -->
<dict>
<key>
name
</key>
<string>
diff header from
</string>
<key>
scope
</key>
<string>
meta.diff.header.from-file
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#FFDDDD
</string>
<key>
fontStyle
</key>
<string></string>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
diff header to
</string>
<key>
scope
</key>
<string>
meta.diff.header.to-file
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#DDFFDD
</string>
<key>
fontStyle
</key>
<string></string>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
diff inserted
</string>
<key>
scope
</key>
<string>
markup.inserted.diff
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#DDFFDD
</string>
<key>
fontStyle
</key>
<string></string>
</dict>
</dict>
<dict>
<key>
name
</key>
<string>
diff deleted
</string>
<key>
scope
</key>
<string>
markup.deleted.diff
</string>
<key>
settings
</key>
<dict>
<key>
background
</key>
<string>
#FFDDDD
</string>
<key>
fontStyle
</key>
<string></string>
<key>
foreground
</key>
<string>
#000000
</string>
</dict>
</dict>
<!-- BracketHighlighter colors -->
<dict>
<key>
name
</key>
<string>
BH Color
</string>
<key>
scope
</key>
<string>
brackethighlighter.default
</string>
<key>
settings
</key>
<dict>
<key>
foreground
</key>
<string>
#FF992244
</string>
<key>
fontStyle
</key>
<string>
italic
</string>
</dict>
</dict>
</array>
<key>
uuid
</key>
<string>
26786979-843B-4FE2-BCB6-4FCEC6F8FB58
</string>
<key>
colorSpaceName
</key>
<string>
sRGB
</string>
<key>
semanticClass
</key>
<string>
theme.light.git_hub_clean_white
</string>
<key>
comment
</key>
<string>
v1.0 Feb 1, 2015
Made to look as close to GitHub as possible.
</string>
</dict>
</plist>
This diff is collapsed.
Click to expand it.
ring-buffer/ring-buffer.pdf
0 → 100644
+
0
−
0
View file @
44efaf2f
File added
This diff is collapsed.
Click to expand it.
ring-buffer/ring-buffer.typ
0 → 100644
+
109
−
0
View file @
44efaf2f
#
import
"
@preview/touying:0.6.1
"
:
*
#
import
themes
.
metropolis
:
*
#
import
"
@preview/cetz:0.3.4
"
#
import
"
@preview/codly:1.3.0
"
:
*
#
import
"
@preview/codly-languages:0.1.8
"
:
*
#
set
raw
(
theme
:
"
mpoquet.tmTheme
"
)
#
show
:
codly
-
init
.
with
()
#
codly
(
display
-
name
:
false
)
#
show
strong
:
it
=>
text
(
fill
:
luma
(
10
%
),
it
)
#
let
cetz
-
canvas
=
touying
-
reducer
.
with
(
reduce
:
cetz
.
canvas
,
cover
:
cetz
.
draw
.
hide
.
with
(
bounds
:
true
))
#
show
:
metropolis
-
theme
.
with
(
aspect
-
ratio
:
"
16-9
"
,
footer
:
self
=>
self
.
info
.
institution
,
config
-
info
(
title
:
[
Ring
buffer
]
,
subtitle
:
[
_
and
in
the
darkness
bind
them_
]
,
author
:
[
Millian
#
smallcaps
[
Poquet
]]
,
date
:
[
2025-04-29
]
,
),
)
#
title
-
slide
()
==
Qu
'
est-ce à dire que ceci ?
Différents noms pour la même chose : `(ring|cyclic|circular) (buffer|queue|array)`
Accès
- `put` : ajout d
'
un
é
l
é
ment
-
`
get
`
:
r
é
cup
é
ration
d
'
un élément
Éléments clés
- Sémantique de file : les éléments ajoutés en premier sont récupérés en premier
- Buffer à *taille fixe* de `N` cases
- Utilisation de deux indices : têtes de lecture `r` et d
'
é
criture
`
w
`
Utilit
é
-
S
é
quen
ç
age
d
'
information entre deux composants matériels
- File de messages (synchronisée) entre deux composants logiciels
== Exemple d
'
ex
é
cution
#
let
ringbuf
(
buf
,
w
,
r
)
=
cetz
-
canvas
(
{
import
cetz
.
draw
:
*
grid
((
0
,
0
),
(
buf
.
len
(),
1
),
step
:
1
)
translate
(
x
:
.5
,
y
:
.5
)
for
i
in
range
(
buf
.
len
())
{
content
((
i
,
0
),
[
#
buf
.
at
(
i
)
]
)
}
translate
(
y
:
-0.75
)
if
(
w
!=
r
)
{
content
((
r
,
0
),
[
`
r
`
]
)
content
((
w
,
0
),
[
`
w
`
]
)
}
else
{
content
((
r
,
0
),
[
`
rw
`
]
)
}
}
)
#
grid
(
columns
:
2
,
column
-
gutter
:
3
cm
,
align
:
top
,
grid
(
columns
:
2
,
column
-
gutter
:
1
cm
,
row
-
gutter
:
5
mm
,
align
:
left
+
top
,
[
`
init
(
4
,
0
,
0
)
`
]
,
ringbuf
((
[]
,
[]
,
[]
,
[]
),
0
,
0
),
pause
,
[
`
put
(
3
)
`
]
,
ringbuf
((
3
,
[]
,
[]
,
[]
),
1
,
0
),
pause
,
[
`
put
(
5
)
`
]
,
ringbuf
((
3
,
5
,
[]
,
[]
),
2
,
0
),
pause
,
[
`
put
(
7
)
`
]
,
ringbuf
((
3
,
5
,
7
,
[]
),
3
,
0
),
pause
,
[
`
get
()
→
3
`
]
,
ringbuf
((
3
,
5
,
7
,
[]
),
3
,
1
),
pause
,
[
`
put
(
11
)
`
]
,
ringbuf
((
3
,
5
,
7
,
11
),
0
,
1
),
pause
,
),
[
#
grid
(
columns
:
2
,
column
-
gutter
:
1
cm
,
row
-
gutter
:
5
mm
,
align
:
left
+
top
,
[
`
put
(
13
)
`
]
,
ringbuf
((
13
,
5
,
7
,
11
),
1
,
1
),
pause
,
[
`
put
(
17
)
`
]
,
[
???
]
)
#
pause
#
v
(
1
cm
)
Plusieurs
choix
possibles
selon
l
'
implémentation !
- `put` renvoie une erreur : le buffer est plein.
- `put` bloque jusqu
'
à
ce
que
`
5
`
soit
r
é
cup
é
r
é
.
-
`
put
`
é
crase
`
5
`
.
#
h
(
1
cm
)
#
box
(
baseline
:
100
%
,
inset
:
(
top
:
-5
mm
),
ringbuf
((
13
,
17
,
7
,
11
),
2
,
1
))
]
,
)
==
Pseudocode
d
'
implémentation — variante _écrase_
```py
N = 4
buf = [0, 0, 0, 0]
w = 0
r = 0
def put(elem):
buf[w] = elem
w = (w + 1) % N
def get():
val = buf[r]
r = (r + 1) % N
return val
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment