From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@redhat.com>
Cc: netdev@oss.sgi.com, devik <devik@cdi.cz>, jamal <hadi@cyberus.ca>
Subject: [PATCH 2.6 1/4]: Add rb_last()
Date: Sat, 14 Aug 2004 22:00:14 +0200 [thread overview]
Message-ID: <411E6F4E.6010705@trash.net> (raw)
[-- 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
reply other threads:[~2004-08-14 20:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=411E6F4E.6010705@trash.net \
--to=kaber@trash.net \
--cc=davem@redhat.com \
--cc=devik@cdi.cz \
--cc=hadi@cyberus.ca \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).