Does anybody have ideas about how to implement a simple circular
buffer? I'm not sure if I am using the term circular buffer correctly
so I'll try and explain what I'm looking for.
For example if the buffer were only five bytes long, and the data
'Hello World' was put into the buffer it would appear to move like
this...
byte 0-> . . . . . <- byte 5 ; Init
byte 0-> . . . . H <- byte 5 ; 1
byte 0-> . . . H e <- byte 5 ; 2
byte 0-> . . H e l <- byte 5 ; 3
byte 0-> . H e l l <- byte 5 ; 4
byte 0-> H e l l o <- byte 5 ; 5
byte 0-> e l l o <- byte 5 ; 6
byte 0-> l l o W <- byte 5 ; 7
New data would always enter the buffer at the bottom, pushing old data
up. Any data that could not fit in the buffer would fall off the top.
Any help will be greatly appreciated. Thanks
*If Marriage is outlawed, only outlaws will have inlaws!
benjamin.l.mcgee@purgatoire.org
Benjamin L McGee on 1/15:7
--- FLAME v1.1
---------------
* Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
|