Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

FindInAscending.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Column_FindInAscending_h
00002 #define Impala_Core_Column_FindInAscending_h
00003 
00004 #include "Core/Column/InvalidColumn.h"
00005 
00006 namespace Impala
00007 {
00008 namespace Core
00009 {
00010 namespace Column
00011 {
00012 
00013 
00014 template <class C>
00015 inline int
00016 FindInAscending(C* col, typename C::ColElemType elem)
00017 {
00018     return FindInAscending(col, elem, 0, col->Capacity());
00019 }
00020 
00021 template <class C>
00022 inline int
00023 FindInAscending(C* col, typename C::ColElemType elem, int start, int end)
00024 {
00025     if (end == -1)
00026         end = col->Capacity();
00027     int low = start;
00028     int high = end - 1;
00029     while (low <= high)
00030     {
00031         int mid = (low + high) / 2;
00032         typename C::ColElemType colVal = col->Get(mid);
00033         if (colVal > elem)
00034             high = mid - 1;
00035         else if (colVal < elem)
00036             low = mid + 1;
00037         else
00038             return mid; // found
00039     }
00040     return end; // not found
00041 }
00042 
00043 inline int
00044 FindInAscending(InvalidColumn* col, InvalidColumn::ColElemType elem, int start,
00045                 int end)
00046 {
00047     // ignore
00048     return 0;
00049 }
00050 
00051 } // namespace Column
00052 } // namespace Core
00053 } // namespace Impala
00054 
00055 #endif

Generated on Fri Mar 19 09:31:04 2010 for ImpalaSrc by  doxygen 1.5.1