Commit Graph

51 Commits

Author SHA1 Message Date
Lawrence Stewart
7ecb40192e Add new FOREACH_FROM variants of the queue(3) FOREACH macros which can
optionally start the traversal from a previously found element by passing the
element in as "var". Passing a NULL "var" retains the same semantics as the
regular FOREACH macros.

Kudos to phk for suggesting the "FROM" suffix instead of my original proposal.

Reviewed by:	jhb (previous version), rpaulo
MFC after:	1 week
2013-06-18 02:57:56 +00:00
Eitan Adler
bc1062559e Start sentences on new lines. 2013-05-09 02:04:28 +00:00
Ed Schouten
4170b08388 Implement LIST_PREV().
Regular LISTs have been implemented in such a way that the prev-pointer
does not point to the previous element, but to the next-pointer stored
in the previous element. This is done to simplify LIST_REMOVE(). This
macro can be implemented without knowing the address of the list head.

Unfortunately this makes it harder to implement LIST_PREV(), which is
why this macro was never here. Still, it is possible to implement this
macro. If the prev-pointer points to the list head, we return NULL.
Otherwise we simply subtract the offset of the prev-pointer within the
structure.

It's not as efficient as traversing forward of course, but in practice
it shouldn't be that bad. In almost all use cases, people will want to
compare the value returned by LIST_PREV() against NULL, so an optimizing
compiler will not emit code that does more branching than TAILQs.

While there, make the code a bit more readable by introducing
__member2struct(). This makes STAILQ_LAST() far more readable.

MFC after:	1 month
2012-09-12 21:03:48 +00:00
Ralf S. Engelschall
f92578026d Fix a little typo and get rid of a cryptic description by aligning the
text to the remaining description.

Approved by: re
2011-09-02 18:13:46 +00:00
Matthew D Fleming
359295cd2a Note that the _SWAP operation is supported for all list/queue types.
Also place STAILQ_REMOVE_HEAD in alphabetical order.  Lastly, document
the _SWAP macros.

PR:		kern/143033
MFC after:	1 week
2011-05-13 15:49:23 +00:00
Gavin Atkinson
cf80e937bb Remove a bullet point that appears to have been accidentally inserted twice.
It has also been included within the feature lists to which it is relevant.

Submitted by:	tobez
MFC after:	1 week
2011-01-11 13:33:42 +00:00
Simon L. B. Nielsen
b9ec8f3b6c Cross reference tree(3) and queue(3).
MFC after:	1 week
2010-07-18 08:34:44 +00:00
Christian Brueffer
ad035daf08 Fix typo.
PR:		140615
Submitted by:	Andrius Morkunas <hinokind@gmail.com>
MFC after:	3 days
2009-11-17 07:06:41 +00:00
Ed Schouten
3d98b75bac Rename the queue macros I introduced last year.
Last year I added SLIST_REMOVE_NEXT and STAILQ_REMOVE_NEXT, to remove
entries behind an element in the list, using O(1) time. I recently
discovered NetBSD also has a similar macro, called SLIST_REMOVE_AFTER.
In my opinion this approach is a lot better:

- It doesn't have the unused first argument of the list pointer. I added
  this, mainly because OpenBSD also had it.

- The _AFTER suffix makes a lot more sense, because it is related to
  SLIST_INSERT_AFTER. _NEXT is only used to iterate through the list.

The reason why I want to rename this now, is to make sure we don't
release a major version with the badly named macros.
2009-05-27 19:28:04 +00:00
Ed Schouten
e2fd72de44 Introduce REMOVE_NEXT() macro's for SLIST and STAILQ.
Even though single linked lists allow items to be removed at constant time
(when the previous element is known), the queue macro's don't allow this.
Implement new REMOVE_NEXT() macro's. Because the REMOVE() macro's also
contain the same code, make it call REMOVE_NEXT().

The OpenBSD version of SLIST_REMOVE_NEXT() needs a reference to the list
head, even though it is unused. We'd better mimic this. The STAILQ version
also needs a reference to the list. This means the prototypes of both
macro's are the same.

Approved by:	philip (mentor)
PR:		kern/121117
2008-05-22 14:40:03 +00:00
David E. O'Brien
ed741d4e2d Don't imply O(n) removal for the doubly linked data structures. 2007-11-02 00:34:44 +00:00
Ruslan Ermilov
81ae4b8da9 Markup fixes. 2006-09-18 15:24:20 +00:00
Ed Maste
d5fd66e17d The removal of CIRCLEQ left four queue macros. One sentence was missed
in the man page update.

PR:		docs/94938
Submitted by:	Ed Schouten <ed@fxq.nl>
MFC After:	3 days
2006-03-25 23:11:10 +00:00
Kirk McKusick
982ba1cb7e Typesetting fix for -r1.137.
If a tail queue is empty the return value of TAILQ_LAST is not
undefined, it is NULL.

Submitted by: Ruslan Ermilov <ru@FreeBSD.org>
2006-03-24 07:41:12 +00:00
Kirk McKusick
c4e29cccdd If a tail queue is empty the return value is not
undefined, it is NULL.
2006-03-22 02:40:38 +00:00
John Baldwin
e26af7a74a Remove a spurious newline. The TAILQ_INIT() is part of the 'faster tailq
deletion' example.

MFC after:	1 week
2005-10-17 17:53:17 +00:00
Tom Rhodes
ddbb94ad96 Some grammar, spelling, and mdoc(7) fixes. No content changes.
PR:		75581
Submitted by:	Nobuyuki Koganemaru n-kogane@syd.odn.ne.jp (original version)
2004-12-29 00:11:34 +00:00
Ruslan Ermilov
2410103c1d mdoc(7) fixes. 2004-07-07 19:57:16 +00:00
Mike Pritchard
3b96c71f73 Spelling fixes. 2004-06-21 14:54:43 +00:00
Alexander Kabaev
2724bce2d2 Add safe _FOREACH iterators to the rest of the queue.h types. 2003-08-14 14:49:26 +00:00
Bosko Milekic
4250a68e2d Document LIST_FOREACH_SAFE in queue(3).
Asked with "please" by Ruslan Ermilov.  I've always had a weakness
for "please".
2003-08-13 19:58:38 +00:00
Thomas Moestl
d57e28adb2 Document STAILQ_CONCAT and TAILQ_CONCAT.
PR:		20024
Submitted by:	Tony Finch <dot@dotat.at> (TAILQ_CONCAT, slightly changed
		by me)
Reviewed by:	ru (earlier version)
2002-04-17 13:48:14 +00:00
Ruslan Ermilov
fb5293cf53 mdoc(7) police: tidy up previous delta. 2002-01-09 15:32:25 +00:00
Julian Elischer
5e7cbd4365 Document some behaviour I'm depending on.
(TAILQ_FOREACH leaves the variable NULL if there were no more to do)
2001-12-28 22:00:27 +00:00
Ruslan Ermilov
32eef9aeb1 mdoc(7) police: Use the new .In macro for #include statements. 2001-10-01 16:09:29 +00:00
Maxim Sobolev
f36b6e4bbb STAILQ_LAST() macro takes 3 arguments, not 1. 2001-08-21 06:19:29 +00:00
Jens Schweikhardt
c1f3e4bf21 Removed whitespace at end-of-line; no content changes. I simply did
cd src/share; find man[1-9] -type f|xargs perl -pi -e 's/[ \t]+$//'

BTW, what editors are the culprits? I'm using vim and it shows
me whitespace at EOL in troff files with a thick blue block...

Reviewed by:	Silence from cvs diff -b
MFC after:	7 days
2001-07-14 19:41:16 +00:00
Ruslan Ermilov
3d45e180f4 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 15:31:11 +00:00
Dima Dorfman
b86388c179 Remove the last remnants of circle queues.
PR:		25184
Submitted by:	Alex Kapranoff <alex@kapran.bitmcnit.bryansk.su>
Approved by:	nik
2001-03-15 02:08:44 +00:00
Ben Smithurst
b4660c3783 Remove comma after final .Nm entry before .Nd 2000-12-30 18:58:15 +00:00
Poul-Henning Kamp
24b85d18c5 CIRCLEQs are a disgrace to everything Knuth taught us in Volume 1 Chapter 2.
Retire them before anybody starts to use them again.

Use TAILQ instead, it provides the same functionality.
2000-12-29 09:55:40 +00:00
Alfred Perlstein
ce900f0398 Manpage incorrectly states that STAILQ_REMOVE_HEAD takes an arg
called 'elm'.  It doesn't take an arg 'elm', it simply removes the
element at the head of the list.
2000-11-09 23:34:39 +00:00
Mark Murray
d6c6381834 Fix minor typo. 2000-07-27 19:13:32 +00:00
Jake Burkholder
03763fe07f (1) document *_HEAD_INITIALIZER
(2) fix a STAILQ_HEAD that should have been STAILQ_FIRST

Requested by:	(1) bde
		(2) W Gerald Hicks <jhix@mindspring.com>
2000-06-10 16:41:07 +00:00
Archie Cobbs
6c1d0fbf06 Document TAILQ_FOREACH_REVERSE() and CIRCLEQ_FOREACH_REVERSE() macros.
Submitted by:	Jake Burkholder <jburkhol@home.com>
2000-05-01 18:22:59 +00:00
John Baldwin
266e33fd51 Update STAILQ example to use STAILQ_REMOVE_HEAD instead of
TAILQ_REMOVE_HEAD.

PR:		docs/17590
Submitted by:	Benno Rice <benno@netizen.com.au>
2000-03-27 13:26:45 +00:00
Alexey Zelkin
79ea9bc4f5 Sync with reality.
PR:		docs/15036
Submitted by:	Jake Burkholder <jburkhol@home.com>
1999-12-19 19:12:14 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Joseph Koshy
9c727d2ca9 Spelling corrections.
PR: 6868
Submitted by: Josh Gilliam <josh@quick.net>
1998-06-06 05:50:53 +00:00
Bruce Evans
02a98699c2 Fixed wrong number of args in STAILQ_REMOVE_HEAD() in synopsis. 1997-03-19 02:57:50 +00:00
Mike Pritchard
6aea1c7c74 The CIRCLEQ_ENTRY example was wrong. Part of PR# 2917. 1997-03-09 00:49:00 +00:00
John-Mark Gurney
ac5afce161 add missing cvs Id lines. 1997-03-07 03:28:23 +00:00
Mike Pritchard
8f20a914b6 Minor mdoc cleanup. 1997-01-31 00:38:18 +00:00
Poul-Henning Kamp
aea88892fd Add SLIST_EMPTY, SLIST_FIRST, SLIST_NEXT.
Is it time to split this into one "intro" type and a number of
detailed pages ?
1996-12-29 21:21:16 +00:00
Mike Pritchard
21421932f5 Use the .Bx macro where appropriate. 1996-08-22 23:39:32 +00:00
Mike Pritchard
d3df5ce12e Another man page with a messed up .Dd line. 1996-07-11 02:57:03 +00:00
Poul-Henning Kamp
c5c15c162f Document 5 new macros in TAILQ family. 1996-04-08 07:54:04 +00:00
Justin T. Gibbs
4a775e8f68 Update the queue man page for the new SLIST and STAILQ macros. 1996-03-31 03:23:16 +00:00
Justin T. Gibbs
3652ff557d 4.4Lite2 implemented the LIST_INSERT_BEFORE and TAILQ_INSERT_BEFORE
exactly as I did (should have checked there first I guess) except my
macro for TAILQ_INSERT_BEFORE took an unneeded arg.  We now match 4.4Lite2.

Suggested by: Jeffrey Hsu <hsu@FreeBSD.org>
1996-02-12 08:20:54 +00:00
Justin T. Gibbs
7658b0a216 Add LIST_INSERT_BEFORE and TAILQ_INSERT_BEFORE.
Change examples to actually free() the nodes removed from lists.
Give examples of faster list deletion routines.
1996-01-29 03:23:05 +00:00