TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: BENJAMIN L MCGEE
from: KURT WISMER
date: 1998-01-15 14:55:00
subject: circular buffer

 -=> Mocking Benjamin L Mcgee to All <=-
   
 BLM> Does anybody have ideas about how to implement a simple circular 
 BLM> buffer?  I'm not sure if I am using the term circular buffer correctly
 BLM> so I'll try and explain what I'm looking for. 
 BLM> 
 BLM> For example if the buffer were only five bytes long, and the data 
 BLM> 'Hello World' was put into the buffer it would appear to move like 
 BLM> this... 
 BLM> 
 BLM> byte 0-> . . . . . <- byte 5        ; Init 
 BLM> byte 0-> . . . . H <- byte 5        ; 1 
 BLM> byte 0-> . . . H e <- byte 5        ; 2  
 BLM> byte 0-> . . H e l <- byte 5        ; 3 
 BLM> byte 0-> . H e l l <- byte 5        ; 4  
 BLM> byte 0-> H e l l o <- byte 5        ; 5 
 BLM> byte 0-> e l l o   <- byte 5        ; 6 
 BLM> byte 0-> l l o   W <- byte 5        ; 7 
 BLM> 
 BLM> New data would always enter the buffer at the bottom, pushing old data
 BLM> up.  Any data that could not fit in the buffer would fall off the top.
 BLM> 
 BLM> Any help will be greatly appreciated.  Thanks 
if i'm reading your message correctly, i get the impression that you're
thinking a circular buffer actually rotates (that you put the data in at
the same place each time and the buffer rotates it out of the way for
you)...
my understanding of a circular buffer is that you simply start over at
the beginning of a fixed length buffer once you've reached the end of
it... and keep pointers to the locations in memory where the next read
and next write are supposed to act... (when one of those pointers is
incremented beyond the range of the buffer, you simply set it back to
the starting point in the buffer)... you also have to figure out how to
keep the algorithm from writing to an occupied space in the buffer or
reading from an empty place in it..
it's a lot easier and more efficient than actually moving all the data in
the buffer by one byte/word/whatever each time you put something in it...
... today's mock has been brought to you by the letters p, u, and # pi...
--- TGWave v1.20.b09
---------------
* Origin: fks Online! * Mississauga, ON Canada (1:259/423)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.