Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

SearchAlgorithms.h File Reference

This file contains templated search functions. More...

#include "CompareAlgorithms.h"

Go to the source code of this file.

Functions

template<class Datatype>
Datatype * BSearch (Datatype *Key, Datatype *Base, int Size, ACompareNodesAlgorithm< Datatype, void > *Compare)
 A templated standard binary search function.
template<class Datatype>
Datatype * FreecellSolverBSearch (Datatype *Key, Datatype *Array, int Length, ACompareNodesAlgorithm< Datatype, void > *Compare, bool *Found)
 An improved binary search function.
template<class Datatype>
void SFOMergeLargeAndSmallSortedArrays (Datatype *BigArray, int BigArraySize, Datatype *SmallArray, int SmallArraySize, ACompareNodesAlgorithm< Datatype, void > *Compare)
 Merges a large sorted array with a small sorted array.


Detailed Description

Author:
Michael Mann
Version:
1.0
Date:
August 2002

Definition in file SearchAlgorithms.h.


Function Documentation

template<class Datatype>
Datatype* BSearch Datatype *  Key,
Datatype *  Base,
int  Size,
ACompareNodesAlgorithm< Datatype, void > *  Compare
 

Parameters:
Key is the value being searched for
Base is the array being searching
Size is the size of the array
Compare is the compare algorithm to compare values in the array
Returns:
Returns the found value. Return NULL if not found

Definition at line 22 of file SearchAlgorithms.h.

References ACompareNodesAlgorithm< Data, ConfigData >::Compare().

template<class Datatype>
Datatype* FreecellSolverBSearch Datatype *  Key,
Datatype *  Array,
int  Length,
ACompareNodesAlgorithm< Datatype, void > *  Compare,
bool *  Found
 

This is based off of the implementation of Shlomi Fish's (shlomif@vipe.technion.ac.il) binary search algorithm written in C

Parameters:
Key is the value being searched for
Array is the array being searching
Length is the size of the array
Compare is the compare algorithm to compare values in the array
Found determines whether or not the item was found
Returns:
Returns item if found. If not found, the function returns the place in which it should be placed

Definition at line 58 of file SearchAlgorithms.h.

References ACompareNodesAlgorithm< Data, ConfigData >::Compare().

template<class Datatype>
void SFOMergeLargeAndSmallSortedArrays Datatype *  BigArray,
int  BigArraySize,
Datatype *  SmallArray,
int  SmallArraySize,
ACompareNodesAlgorithm< Datatype, void > *  Compare
 

The arrays could be of any length whatsoever, but it works faster if the first is significantly bigger than the second. This function assumes that big_array is allocated with enough space to hold the extra elements. The arrays should be distinct or else there would be unexpected results.

Parameters:
BigArray is the larger of the two arrays
BigArraySize is the size of the larger array
SmallArray is the smaller of the two arrays
SmallArraySize is the size of the smaller array
Compare is the compare algorithm to compare values in the array

Definition at line 102 of file SearchAlgorithms.h.


Generated on Sat Nov 5 11:20:16 2005 for Cpp Freecell Solver by  doxygen 1.4.4