This adds get_next functions to the various maps (flexi, quick and map).

get_next searches for the 1st entry whose key is > the key specified.

As such get_next provides for searches where an exact key is not known,
or the map may be changing between searches (and hence the key of a
previously fetched entry may no longer be in the map).

This patch was generated against OFED 1.2, however I have diffed the
affected files and the files in the master are identical.

Signed-off-by: Todd Rimmer <[EMAIL PROTECTED]>

diff -r -c orig2/osm/complib/cl_map.c fixed/osm/complib/cl_map.c
*** orig2/osm/complib/cl_map.c  Wed Jun 20 08:57:45 2007
--- fixed/osm/complib/cl_map.c  Wed Jun 20 09:41:55 2007
***************
*** 268,273 ****
--- 268,300 ----
        return( p_item );
  }
  
+ cl_map_item_t*
+ cl_qmap_get_next(
+       IN      const cl_qmap_t* const  p_map,
+       IN      const uint64_t                  key )
+ {
+       cl_map_item_t   *p_item;
+       cl_map_item_t   *p_item_found;
+ 
+       CL_ASSERT( p_map );
+       CL_ASSERT( p_map->state == CL_INITIALIZED );
+ 
+       p_item = __cl_map_root( p_map );
+       p_item_found = (cl_map_item_t*)&p_map->nil;
+ 
+       while( p_item != &p_map->nil )
+       {
+               if( key < p_item->key ){
+                       p_item_found = p_item;
+                       p_item = p_item->p_left;
+               }else{
+                       p_item = p_item->p_right;
+               }
+       }
+     
+       return( p_item_found );
+ }
+ 
  void
  cl_qmap_apply_func(
        IN      const cl_qmap_t* const  p_map,
***************
*** 832,837 ****
--- 859,881 ----
        return( cl_qmap_obj( PARENT_STRUCT( p_item, cl_map_obj_t, item )
) );
  }
  
+ void*
+ cl_map_get_next(
+       IN      const cl_map_t* const   p_map,
+       IN      const uint64_t                  key )
+ {
+       cl_map_item_t   *p_item;
+ 
+       CL_ASSERT( p_map );
+ 
+       p_item = cl_qmap_get_next( &p_map->qmap, key );
+ 
+       if( p_item == cl_qmap_end( &p_map->qmap ) )
+               return( NULL );
+ 
+       return( cl_qmap_obj( PARENT_STRUCT( p_item, cl_map_obj_t, item )
) );
+ }
+ 
  void
  cl_map_remove_item(
        IN      cl_map_t* const                 p_map,
***************
*** 1279,1284 ****
--- 1323,1358 ----
        return( p_item );
  }
  
+ cl_fmap_item_t*
+ cl_fmap_get_next(
+       IN      const cl_fmap_t* const  p_map,
+       IN      const void* const               p_key )
+ {
+       cl_fmap_item_t  *p_item;
+       cl_fmap_item_t  *p_item_found;
+       intn_t                  cmp;
+ 
+       CL_ASSERT( p_map );
+       CL_ASSERT( p_map->state == CL_INITIALIZED );
+ 
+       p_item = __cl_fmap_root( p_map );
+       p_item_found = (cl_fmap_item_t*)&p_map->nil;
+ 
+       while( p_item != &p_map->nil )
+       {
+               cmp = p_map->pfn_compare( p_key, p_item->p_key );
+ 
+               if( cmp < 0 ){
+                       p_item_found = p_item;
+                       p_item = p_item->p_left;        /* too small */
+               }else{
+                       p_item = p_item->p_right;       /* too big or
match */
+               }
+       }
+ 
+       return( p_item_found );
+ }
+ 
  void
  cl_fmap_apply_func(
        IN      const cl_fmap_t* const  p_map,
diff -r -c orig2/osm/include/complib/cl_fleximap.h
fixed/osm/include/complib/cl_fleximap.h
*** orig2/osm/include/complib/cl_fleximap.h     Wed Jun 20 08:57:45 2007
--- fixed/osm/include/complib/cl_fleximap.h     Wed Jun 20 09:30:30 2007
***************
*** 100,106 ****
  *
  *     Manipulation:
  *             cl_fmap_insert, cl_fmap_get, cl_fmap_remove_item,
cl_fmap_remove,
! *             cl_fmap_remove_all, cl_fmap_merge, cl_fmap_delta
  *
  *     Search:
  *             cl_fmap_apply_func
--- 100,106 ----
  *
  *     Manipulation:
  *             cl_fmap_insert, cl_fmap_get, cl_fmap_remove_item,
cl_fmap_remove,
! *             cl_fmap_remove_all, cl_fmap_merge, cl_fmap_delta,
cl_fmap_get_next
  *
  *     Search:
  *             cl_fmap_apply_func
***************
*** 672,678 ****
  *     cl_fmap_get does not remove the item from the flexi map.
  *
  * SEE ALSO
! *     Flexi Map, cl_fmap_remove
  *********/
  
  /****f* Component Library: Flexi Map/cl_fmap_remove_item
--- 672,714 ----
  *     cl_fmap_get does not remove the item from the flexi map.
  *
  * SEE ALSO
! *     Flexi Map, cl_fmap_remove, cl_fmap_get_next
! *********/
! 
! /****f* Component Library: Flexi Map/cl_fmap_get_next
! * NAME
! *     cl_fmap_get_next
! *
! * DESCRIPTION
! *     The cl_fmap_get_next function returns the first map item
associated with a
! *     key > the key specified.
! *
! * SYNOPSIS
! */
! cl_fmap_item_t*
! cl_fmap_get_next(
!       IN      const cl_fmap_t* const  p_map,
!       IN      const void* const               p_key );
! /*
! * PARAMETERS
! *     p_map
! *             [in] Pointer to a cl_fmap_t structure from which to
retrieve the
! *             item with the specified key.
! *
! *     p_key
! *             [in] Pointer to a key value used to search for the
desired map item.
! *
! * RETURN VALUES
! *     Pointer to the first map item with a key > the  desired key
value.
! *
! *     Pointer to the map end if there was no item with a key > the
desired key
! *     value stored in the flexi map.
! *
! * NOTES
! *     cl_fmap_get_next does not remove the item from the flexi map.
! *
! * SEE ALSO
! *     Flexi Map, cl_fmap_remove, cl_fmap_get
  *********/
  
  /****f* Component Library: Flexi Map/cl_fmap_remove_item
diff -r -c orig2/osm/include/complib/cl_map.h
fixed/osm/include/complib/cl_map.h
*** orig2/osm/include/complib/cl_map.h  Wed Jun 20 08:57:45 2007
--- fixed/osm/include/complib/cl_map.h  Wed Jun 20 09:30:51 2007
***************
*** 96,102 ****
  *
  *     Manipulation
  *             cl_map_insert, cl_map_get, cl_map_remove_item,
cl_map_remove,
! *             cl_map_remove_all, cl_map_merge, cl_map_delta
  *
  *     Attributes:
  *             cl_map_count, cl_is_map_empty, cl_is_map_inited
--- 96,102 ----
  *
  *     Manipulation
  *             cl_map_insert, cl_map_get, cl_map_remove_item,
cl_map_remove,
! *             cl_map_remove_all, cl_map_merge, cl_map_delta,
cl_map_get_next
  *
  *     Attributes:
  *             cl_map_count, cl_is_map_empty, cl_is_map_inited
***************
*** 628,634 ****
  *     cl_map_get does not remove the item from the map.
  *
  * SEE ALSO
! *     Map, cl_map_remove
  *********/
  
  /****f* Component Library: Map/cl_map_remove_item
--- 628,670 ----
  *     cl_map_get does not remove the item from the map.
  *
  * SEE ALSO
! *     Map, cl_map_remove, cl_map_get_next
! *********/
! 
! /****f* Component Library: Map/cl_map_get_next
! * NAME
! *     cl_map_get_next
! *
! * DESCRIPTION
! *     The cl_qmap_get_next function returns the first object
associated with a
! *     key > the key specified.
! *
! * SYNOPSIS
! */
! void*
! cl_map_get_next(
!       IN      const cl_map_t* const   p_map,
!       IN      const uint64_t                  key );
! /*
! * PARAMETERS
! *     p_map
! *             [in] Pointer to a map from which to retrieve the object
with
! *             the specified key.
! *
! *     key
! *             [in] Key value used to search for the desired object.
! *
! * RETURN VALUES
! *     Pointer to the first object with a key > the desired key value.
! *
! *     NULL if there was no item with a key > the desired key
! *     value stored in the map.
! *
! * NOTES
! *     cl_map_get does not remove the item from the map.
! *
! * SEE ALSO
! *     Map, cl_map_remove, cl_map_get
  *********/
  
  /****f* Component Library: Map/cl_map_remove_item
diff -r -c orig2/osm/include/complib/cl_qmap.h
fixed/osm/include/complib/cl_qmap.h
*** orig2/osm/include/complib/cl_qmap.h Wed Jun 20 08:57:45 2007
--- fixed/osm/include/complib/cl_qmap.h Wed Jun 20 09:43:19 2007
***************
*** 98,104 ****
  *
  *     Manipulation:
  *             cl_qmap_insert, cl_qmap_get, cl_qmap_remove_item,
cl_qmap_remove,
! *             cl_qmap_remove_all, cl_qmap_merge, cl_qmap_delta
  *
  *     Search:
  *             cl_qmap_apply_func
--- 98,104 ----
  *
  *     Manipulation:
  *             cl_qmap_insert, cl_qmap_get, cl_qmap_remove_item,
cl_qmap_remove,
! *             cl_qmap_remove_all, cl_qmap_merge, cl_qmap_delta,
cl_qmap_get_next
  *
  *     Search:
  *             cl_qmap_apply_func
***************
*** 749,755 ****
  *     cl_qmap_get does not remove the item from the quick map.
  *
  * SEE ALSO
! *     Quick Map, cl_qmap_remove
  *********/
  
  /****f* Component Library: Quick Map/cl_qmap_remove_item
--- 749,791 ----
  *     cl_qmap_get does not remove the item from the quick map.
  *
  * SEE ALSO
! *     Quick Map, cl_qmap_get_next, cl_qmap_remove
! *********/
! 
! /****f* Component Library: Quick Map/cl_qmap_get_next
! * NAME
! *     cl_qmap_get_next
! *
! * DESCRIPTION
! *     The cl_qmap_get_next function returns the first map item
associated with a
! *     key > the key specified.
! *
! * SYNOPSIS
! */
! cl_map_item_t*
! cl_qmap_get_next(
!       IN      const cl_qmap_t* const  p_map,
!       IN      const uint64_t                  key );
! /*
! * PARAMETERS
! *     p_map
! *             [in] Pointer to a cl_qmap_t structure from which to
retrieve the
! *             first item with a key > the specified key.
! *
! *     key
! *             [in] Key value used to search for the desired map item.
! *
! * RETURN VALUES
! *     Pointer to the first map item with a key > the desired key
value.
! *
! *     Pointer to the map end if there was no item with a key > the
desired key
! *     value stored in the quick map.
! *
! * NOTES
! *     cl_qmap_get_next does not remove the item from the quick map.
! *
! * SEE ALSO
! *     Quick Map, cl_qmap_get, cl_qmap_remove
  *********/
  
  /****f* Component Library: Quick Map/cl_qmap_remove_item

Todd Rimmer
Chief Architect 
QLogic System Interconnect Group
Voice: 610-233-4852     Fax: 610-233-4777
[EMAIL PROTECTED]  www.QLogic.com
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to