netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6 1/4]: Add rb_last()
@ 2004-08-14 20:00 Patrick McHardy
  0 siblings, 0 replies; only message in thread
From: Patrick McHardy @ 2004-08-14 20:00 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, devik, jamal

[-- Attachment #1: Type: text/plain, Size: 85 bytes --]

This patch adds rb_last which returns the last element in sort-order
from a rbtree.


[-- Attachment #2: 01-hfsc-2.6.diff --]
[-- Type: text/x-patch, Size: 1478 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/08/11 23:09:51+02:00 kaber@coreworks.de 
#   [RBTREE]: Add rb_last()
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
# lib/rbtree.c
#   2004/08/11 23:09:34+02:00 kaber@coreworks.de +13 -0
#   [RBTREE]: Add rb_last()
# 
# include/linux/rbtree.h
#   2004/08/11 23:09:34+02:00 kaber@coreworks.de +1 -0
#   [RBTREE]: Add rb_last()
# 
diff -Nru a/include/linux/rbtree.h b/include/linux/rbtree.h
--- a/include/linux/rbtree.h	2004-08-12 23:25:04 +02:00
+++ b/include/linux/rbtree.h	2004-08-12 23:25:04 +02:00
@@ -123,6 +123,7 @@
 extern struct rb_node *rb_next(struct rb_node *);
 extern struct rb_node *rb_prev(struct rb_node *);
 extern struct rb_node *rb_first(struct rb_root *);
+extern struct rb_node *rb_last(struct rb_root *);
 
 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
 extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, 
diff -Nru a/lib/rbtree.c b/lib/rbtree.c
--- a/lib/rbtree.c	2004-08-12 23:25:04 +02:00
+++ b/lib/rbtree.c	2004-08-12 23:25:04 +02:00
@@ -312,6 +312,19 @@
 }
 EXPORT_SYMBOL(rb_first);
 
+struct rb_node *rb_last(struct rb_root *root)
+{
+	struct rb_node	*n;
+
+	n = root->rb_node;
+	if (!n)
+		return NULL;
+	while (n->rb_right)
+		n = n->rb_right;
+	return n;
+}
+EXPORT_SYMBOL(rb_last);
+
 struct rb_node *rb_next(struct rb_node *node)
 {
 	/* If we have a right-hand child, go down and then left as far

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-14 20:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-14 20:00 [PATCH 2.6 1/4]: Add rb_last() Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).