Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BoundsTracker.cxx

Go to the documentation of this file.
00001 #include "BoundsTracker.h"
00002 
00003 #include <Validity/VldTimeStamp.h>
00004 
00005 #include <iostream>
00006 using namespace std;
00007 
00008 BoundsTracker::BoundsTracker(const FileGap::BoundList& lst)
00009     : fIndex(0)
00010 {
00011     cerr << "BoundList is " << lst.size() << " elements\n";
00012 
00013     FileGap::BoundList::const_iterator it, done = lst.end();
00014     for (it=lst.begin(); it != done; ++it) {
00015         VldTimeStamp a = it->first;
00016         VldTimeStamp b = it->second;
00017 
00018         fList.push_back(pair<VldTimeStamp,VldTimeStamp>(a,b));
00019     }
00020     fItr = fList.begin();
00021 }
00022 int BoundsTracker::InFile(const VldTimeStamp& vts)
00023 {
00024     //cerr << "infile\n";
00025     size_t siz = fList.size();
00026     if (! siz) return -3;
00027     //cerr << "InFile("<< vts<<"), list size="<<siz<<"\n";
00028 
00029     if (fItr->first <= vts && vts <= fItr->second) return 0;
00030 
00031     if (vts < fItr->first) {
00032         if (fItr == fList.begin()) return -2;
00033         FileGap::BoundList::iterator prev = fItr;
00034         --prev;
00035         if (vts > prev->second) return -1;
00036         fItr = prev;
00037         --fIndex;
00038         return this->InFile(vts);       
00039     }
00040 
00041     if (vts > fItr->second) {
00042         FileGap::BoundList::iterator next = fItr;
00043         ++next;
00044         if (next == fList.end()) return +2;
00045         if (vts < next->first) return +1;
00046         fItr = next;
00047         ++fIndex;
00048         return this->InFile(vts);
00049     }
00050 
00051     return 0;                   // never reach this
00052 }
00053 
00054 int BoundsTracker::GetIndex() const
00055 {
00056     return fIndex;
00057 }
00058 VldTimeStamp BoundsTracker::GetItrFirst()
00059 {
00060     return fItr->first;
00061 }
00062 VldTimeStamp BoundsTracker::GetItrSecond()
00063 {
00064     return fItr->second;
00065 }

Generated on Mon Feb 15 11:06:26 2010 for loon by  doxygen 1.3.9.1