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

aots_s.h

Go to the documentation of this file.
00001 #include<config.h>
00002 CPS_START_NAMESPACE
00003 //--------------------------------------------------------------------
00004 //  CVS keywords
00005 //
00006 //  $Author: zs $
00007 //  $Date: 2004/08/18 11:57:35 $
00008 //  $Header: /space/cvs/cps/cps++/include/alg/aots_s.h,v 1.4 2004/08/18 11:57:35 zs Exp $
00009 //  $Id: aots_s.h,v 1.4 2004/08/18 11:57:35 zs Exp $
00010 //  $Name: v5_0_8 $
00011 //  $Locker:  $
00012 //  $Revision: 1.4 $
00013 //  $Source: /space/cvs/cps/cps++/include/alg/aots_s.h,v $
00014 //  $State: Exp $
00015 //
00016 //--------------------------------------------------------------------
00017 // aots_s.h
00018 #ifndef INCLUDED_AOTS_S_H
00019 #define INCLUDED_AOTS_S_H
00020 
00021 class Aots {
00022 
00023   static char cname[];
00024 
00025   int start;
00026   int end;
00027   int step;
00028   int current;
00029 
00030 public :
00031 
00032   //-----------------------------------------------------------------
00033   // CTOR
00034   //-----------------------------------------------------------------
00035   Aots(int s, int e, int stride);
00036 
00037   //-----------------------------------------------------------------
00038   // DTOR
00039   //-----------------------------------------------------------------
00040   ~Aots() {}
00041 
00042   //-----------------------------------------------------------------
00043   // advancing operator: prefix 
00044   //-----------------------------------------------------------------
00045   Aots & operator++() { current += step; return *this; }
00046 
00047   //-----------------------------------------------------------------
00048   // conversion operator, combined with operator ++, used in the idiom:
00049   //     for(Aots it(); it; ++it){ ... }
00050   //-----------------------------------------------------------------
00051   operator const void *() const { return current <= end ? this : 0; }
00052 
00053   //-----------------------------------------------------------------
00054   // if you don't like the above, here is the alternatives
00055   //-----------------------------------------------------------------
00056   void advance() { current += step; }
00057   int finish() const { return current > end; }
00058 
00059   //-----------------------------------------------------------------
00060   // status of this Aots
00061   //-----------------------------------------------------------------
00062   int begin() const { return start == current; } 
00063   int last() const { return (current+step) > end; }
00064   int slice() const { return current; }
00065 
00066   //-----------------------------------------------------------------
00067   // number of slices of AOTS: minimum = 1
00068   //-----------------------------------------------------------------
00069   int numSlices() { return (current - start)/step + 1; }
00070 };
00071 
00072 #endif
00073 
00074 CPS_END_NAMESPACE

Generated on Sat Oct 10 14:11:10 2009 for Columbia Physics System by  doxygen 1.3.9.1