Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/tl/binsearch.h File Reference

Binary search templates. More...

#include <lib/sconfig.h>
#include <lib/tl/defop.h>

Include dependency graph for binsearch.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define _TemplateLibrary_BINARYSEARCH_H_   1

Functions

template<typename T, typename K> ssize_t BinarySearch (const T *arr, size_t nelem, const K &key)
 Binary search template.

template<typename T, typename K, typename _OP> ssize_t TLBinarySearch (const T *_arr, size_t nelem, const K &key, const _OP &op=TLDefaultOperators_CDT< T >())
 Binary search template for insertion index.

template<typename T, typename K> bool BinarySearch (const T *arr, size_t nelem, const K &key, size_t *ret_idx)
 Binary search template for insertion index.

template<typename T, typename K, typename _OP> bool TLBinarySearch (const T *_arr, size_t nelem, const K &key, size_t *ret_idx, const _OP &op=TLDefaultOperators_CDT< T >())
 Binary search template for insertion index.


Detailed Description

Binary search templates.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [

Definition in file binsearch.h.


Define Documentation

#define _TemplateLibrary_BINARYSEARCH_H_   1
 

Definition at line 18 of file binsearch.h.


Function Documentation

template<typename T, typename K>
bool BinarySearch const T *  arr,
size_t  nelem,
const K key,
size_t *  ret_idx
 

Binary search template for insertion index.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Perform binary search on passed array arr with nelem elements. The array must be sorted in ascenting order.

Returns:
0 -> not found: insertion index stored in ret_idx (0..nelem)
(Insertion index means that the passed object can be stored immediately before element [ret_idx].)
1 -> found: index of first occurance in array stored in ret_idx (0..nelem-1)
NOTE: You may NOT use ret_idx=NULL.

There are different versions of this function; one using an operator class, one using standard C(++) operators.

There is another version of this function available which does not return the insertion index.

This is the version using standard C(++) operators.

Definition at line 105 of file binsearch.h.

template<typename T, typename K>
ssize_t BinarySearch const T *  arr,
size_t  nelem,
const K key
 

Binary search template.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
Perform binary search on array and return index of first occurance of key or -1 if not found.

The array must be sorted in ascenting order.

There is another version of this function available which returns the insertion index.

There are different versions of this function; one using an operator class, one using standard C(++) operators; this is the latter.

Definition at line 46 of file binsearch.h.

References ssize_t.

template<typename T, typename K, typename _OP>
bool TLBinarySearch const T *  _arr,
size_t  nelem,
const K key,
size_t *  ret_idx,
const _OP &  op = TLDefaultOperators_CDT<T>()
 

Binary search template for insertion index.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
This is the same function as BinarySearch() but using an operator class instead of a template.

Definition at line 127 of file binsearch.h.

Referenced by VM::VMLinker::_MergeNamespaceInfo_Recursive(), TLArray< RJumpEntry, RJumpEntry_Operators >::BinSearch(), and TLSortedArray< T, _OP >::search().

template<typename T, typename K, typename _OP>
ssize_t TLBinarySearch const T *  _arr,
size_t  nelem,
const K key,
const _OP &  op = TLDefaultOperators_CDT<T>()
 

Binary search template for insertion index.

Author:
Wolfgang Wieser ] wwieser (a) gmx <*> de [
This is the same function as BinarySearch() but using an operator class instead of a template.

Definition at line 66 of file binsearch.h.

References ssize_t.


Generated on Sat Feb 19 22:34:48 2005 for Ray by doxygen 1.3.5