[rtems commit] rbtree: Delete _RBTree_Get()

Sebastian Huber sebh at rtems.org
Mon Aug 31 08:41:20 UTC 2015


Module:    rtems
Branch:    master
Commit:    b9877ee03d8e8fad88ab42ccdcfc1a61b6801838
Changeset: http://git.rtems.org/rtems/commit/?id=b9877ee03d8e8fad88ab42ccdcfc1a61b6801838

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Aug 21 05:55:04 2015 +0200

rbtree: Delete _RBTree_Get()

This function has no internal use case.

---

 cpukit/sapi/include/rtems/rbtree.h        | 42 +++++++++++++++++++++++--------
 cpukit/score/include/rtems/score/rbtree.h | 31 -----------------------
 2 files changed, 32 insertions(+), 41 deletions(-)

diff --git a/cpukit/sapi/include/rtems/rbtree.h b/cpukit/sapi/include/rtems/rbtree.h
index 8ea3430..4d80073 100644
--- a/cpukit/sapi/include/rtems/rbtree.h
+++ b/cpukit/sapi/include/rtems/rbtree.h
@@ -296,31 +296,53 @@ RTEMS_INLINE_ROUTINE void rtems_rbtree_extract(
 }
 
 /**
- * @brief Obtain the min node on a rbtree.
+ * @brief Gets a node with the minimum key value from the red-black tree.
  *
- * This function removes the min node from @a the_rbtree and returns
- * a pointer to that node.  If @a the_rbtree is empty, then NULL is returned.
+ * This function extracts a node with the minimum key value from
+ * tree and returns a pointer to that node if it exists.  In case multiple
+ * nodes with a minimum key value exist, then they are extracted in FIFO order.
+ *
+ * @param[in] the_rbtree The red-black tree control.
+ *
+ * @retval NULL The tree is empty.
+ * @retval node A node with the minimal key value on the tree.
  */
-
 RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_min(
   rtems_rbtree_control *the_rbtree
 )
 {
-  return _RBTree_Get( the_rbtree, RBT_LEFT );
+  rtems_rbtree_node *the_node = rtems_rbtree_min( the_rbtree );
+
+  if ( the_node != NULL ) {
+    rtems_rbtree_extract( the_rbtree, the_node );
+  }
+
+  return the_node;
 }
 
 /**
- * @brief Obtain the max node on a rbtree.
+ * @brief Gets a node with the maximal key value from the red-black tree.
  *
- * This function removes the max node from @a the_rbtree and returns
- * a pointer to that node.  If @a the_rbtree is empty, then NULL is returned.
+ * This function extracts a node with the maximum key value from tree and
+ * returns a pointer to that node if it exists.  In case multiple nodes with a
+ * maximum key value exist, then they are extracted in LIFO order.
+ *
+ * @param[in] the_rbtree The red-black tree control.
+ *
+ * @retval NULL The tree is empty.
+ * @retval node A node with the maximal key value on the tree.
  */
-
 RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max(
   rtems_rbtree_control *the_rbtree
 )
 {
-  return _RBTree_Get( the_rbtree, RBT_RIGHT );
+  rtems_rbtree_node *the_node = rtems_rbtree_max( the_rbtree );
+
+  if ( the_node != NULL ) {
+    rtems_rbtree_extract( the_rbtree, the_node );
+  }
+
+  return the_node;
 }
 
 /**
diff --git a/cpukit/score/include/rtems/score/rbtree.h b/cpukit/score/include/rtems/score/rbtree.h
index d6d7b34..ea8f4af 100644
--- a/cpukit/score/include/rtems/score/rbtree.h
+++ b/cpukit/score/include/rtems/score/rbtree.h
@@ -522,37 +522,6 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Successor(
   return _RBTree_Next( node, RBT_RIGHT );
 }
 
-/**
- * @brief Gets a node with an extremal key value from the red-black tree.
- *
- * This function extracts a node with the minimum or maximum key value from
- * tree and returns a pointer to that node if it exists.  In case multiple
- * nodes with a minimum key value exist, then they are extracted in FIFO order.
- * In case multiple nodes with a maximum key value exist, then they are
- * extracted in LIFO order.
- *
- * @param[in] the_rbtree The red-black tree control.
- * @param[in] dir Specifies whether to get a node with the minimum (RBT_LEFT)
- *   or maximum (RBT_RIGHT) key value.
- *
- * @retval NULL The tree is empty.
- * @retval extremal_node A node with a minimal or maximal key value on the
- *   tree.
- */
-RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Get(
-  RBTree_Control *the_rbtree,
-  RBTree_Direction dir
-)
-{
-  RBTree_Node *the_node = the_rbtree->first[ dir ];
-
-  if ( the_node != NULL ) {
-    _RBTree_Extract( the_rbtree, the_node );
-  }
-
-  return the_node;
-}
-
 /**@}*/
 
 #ifdef __cplusplus



More information about the vc mailing list