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

IsSorted.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Column_IsSorted_h
00002 #define Impala_Core_Column_IsSorted_h
00003 
00004 #include <iostream>
00005 #include "Core/Column/ColumnTem.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Column
00012 {
00013 
00014 
00017 template <class C>
00018 inline bool
00019 IsSortedAscending(C* col, int nrElem)
00020 {
00021     ILOG_VAR(Impala.Core.Column.IsSortedAscending);
00022     if (col->Capacity() == 0)
00023     {
00024         // no warning in case of empty column
00025         return true;
00026     }
00027     if (nrElem > col->Capacity())
00028     {
00029         ILOG_ERROR("nrElem larger than capacity");
00030         return false;
00031     }
00032     for (int i=0 ; i<nrElem-1 ; i++)
00033         if (col->Get(i) > col->Get(i+1))
00034             return false;
00035     return true;
00036 }
00037 
00040 template <class C>
00041 inline bool
00042 IsSortedDescending(C* col, int nrElem)
00043 {
00044     ILOG_VAR(Impala.Core.Column.IsSortedDescending);
00045     if (nrElem > col->Capacity())
00046     {
00047         ILOG_ERROR("nrElem larger than capacity");
00048         return false;
00049     }
00050 
00051     for (int i=0 ; i<nrElem-1 ; i++)
00052         if (col->Get(i) < col->Get(i+1))
00053             return false;
00054     return true;
00055 }
00056 
00057 
00058 } // namespace Column
00059 } // namespace Core
00060 } // namespace Impala
00061 
00062 #endif

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