Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Examples

labeled_index.h

00001 /* Copyright 2004
00002 Stanford University
00003 
00004 This file is part of the DSR PDB Library.
00005 
00006 The DSR PDB Library is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation; either version 2.1 of the License, or (at your
00009 option) any later version.
00010 
00011 The DSR PDB Library is distributed in the hope that it will be useful, but
00012 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014 License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with the DSR PDB Library; see the file COPYING.LIB.  If not, write to
00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019 MA 02111-1307, USA. */
00020 
00021 #ifndef DSR_PDB_LABELED_INDEX_H
00022 #define DSR_PDB_LABELED_INDEX_H
00023 
00024 #include <cassert>
00025 
00026 namespace dsrpdb {
00027   template <class Type>
00028   struct labeled_index {
00029     typedef labeled_index<Type> This;
00030 
00031     labeled_index(int i): i_(i) {
00032     }
00033     labeled_index():i_(-1){}
00034 
00035     int value() const {
00036       assert(!null());
00037     }
00038 
00039     This operator++() {
00040       ++i_;
00041       return *this;
00042     };
00043 
00044     This operator++(int) {
00045       This ret=*this;
00046       ++i_;
00047       return ret;
00048     };
00049     
00050     This operator+(int v) const {
00051       return This(i_+v);
00052     }
00053 
00054     int i_;
00055   };
00056 }
00057 
00058 #endif