Initial Commit
This commit is contained in:
47
common/BINARRAY.HPP
Normal file
47
common/BINARRAY.HPP
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _COMMON_BINARYSEARCHARRAY_HPP_
|
||||
#define _COMMON_BINARYSEARCHARRAY_HPP_
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
class BinarySearchArray
|
||||
{
|
||||
public:
|
||||
BinarySearchArray(Array<T> &sortedVector);
|
||||
virtual ~BinarySearchArray();
|
||||
WORD searchItem(const T &desiredItem,T &foundItem);
|
||||
WORD searchItem(const T &desiredItem,Block<T> &foundItems);
|
||||
private:
|
||||
WORD searchItem(const T &desiredItem,T &foundItem,LONG &foundIndex);
|
||||
DWORD itemCount(void)const;
|
||||
Array<T> &mSortedVector;
|
||||
DWORD mItemCount;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearchArray<T>::BinarySearchArray(Array<T> &sortedVector)
|
||||
: mSortedVector(sortedVector), mItemCount(mSortedVector.size())
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
BinarySearchArray<T>::~BinarySearchArray(void)
|
||||
{
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
DWORD BinarySearchArray<T>::itemCount(void)const
|
||||
{
|
||||
return mItemCount;
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#include <common/binarray.tpp>
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user