home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.compilers
- Path: sparky!uunet!think.com!spdcc!iecc!compilers-sender
- From: wendt@CS.ColoState.EDU (alan l wendt)
- Subject: Re: Modulo n arithmetics
- Reply-To: wendt@CS.ColoState.EDU (alan l wendt)
- Organization: Colorado State University, Computer Science Department
- Date: Sun, 15 Nov 1992 16:39:06 GMT
- Approved: compilers@iecc.cambridge.ma.us
- Message-ID: <92-11-078@comp.compilers>
- Followup-To: comp.programming
- Keywords: arithmetic
- References: <92-11-029@comp.compilers> <92-11-043@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Lines: 18
-
- Speaking of modulo-n buffering systems. This is really the wrong group
- but I cannot help mentioning that the traditional head-and-tail pointer
- technique for circular buffering is the wrong way to do it. The problem
- is that head==tail can mean that the queue is empty or that the queue is
- full, so most implementations waste a queue entry so that the queue never
- really gets full.
-
- If the algorithm maintains the queue head pointer and the queue length,
- instead of head and tail, the two cases can be disambiguated easily!
-
- Horowitz & Sahni (Fundamentals of Computer Algorithms) suggest that one
- might maintain an additional boolean to disambiguate the two situations,
- which I take as evidence that this idea is not widely disseminated.
-
- Alan Wendt
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-