00001 #ifndef Impala_Core_Column_Reverse_h
00002 #define Impala_Core_Column_Reverse_h
00003
00004 #include <iostream>
00005 #include "Core/Column/ColumnTem.h"
00006 #include "Util/Reverse.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Column
00013 {
00014
00015
00016 template <class C>
00017 inline void
00018 Reverse(C* column)
00019 {
00020 if (column->Capacity() == 0)
00021 return;
00022
00023 Util::Reverse(column->GetData(), 0, column->Capacity()-1);
00024 }
00025
00026 template <class C>
00027 inline void
00028 ReversePart(C* column, int left, int right)
00029 {
00030 if (column->Capacity() == 0)
00031 return;
00032
00033 if(left<0 || right>=column->Capacity())
00034 {
00035 std::cout << "[Column::ReversePart] error: incvalid args\n";
00036 return;
00037 }
00038
00039 Util::Reverse(column->GetData(), 0, column->Capacity()-1);
00040 }
00041
00043 template <>
00044 void
00045 ReversePart(Vector::VectorSet<Array::Array2dScalarReal64>* data, int left, int right)
00046 {
00047 typedef Vector::VectorTem<Array::Array2dScalarReal64::StorType> Type;
00048
00049 if(left<0 || right>=data->Capacity())
00050 {
00051 std::cout << "[Column::ReversePart] error: incvalid args\n";
00052 return;
00053 }
00054
00055 while(left<right)
00056 {
00057 Type temp = data->Get(left);
00058 data->Set(left, data->Get(right));
00059 data->Set(right, temp);
00060 ++left;
00061 --right;
00062 }
00063 }
00064
00066 template <>
00067 void
00068 Reverse(Vector::VectorSet<Array::Array2dScalarReal64>* data)
00069 {
00070 int left = 0;
00071 int right = data->Size()-1;
00072 ReversePart(data, left, right);
00073 }
00074
00075
00076 }
00077 }
00078 }
00079
00080 #endif