/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ // // mbt_val_ord_offset_vec.h // // MBTValOrderedOffsetVector is a derived class of RWTValOrderedVector // that adds the additional functionality of allowing clients to change // the indexing base. Arrays in C and C++ are normally zero based, // which means that myArray[0] references the first element. Since // Phrap (and the community generally) uses 1 based indexing for // arrays of nucleotides, the same convention is used within the // consed code. MBTValOrderedOffsetVector allows the client to // specify an offset other than 0. This is 1 currently. // // the point is to a) avoid sprinkling the code with constructions // like " myArray[userVisibleIndex - 1]" everywhere and b) to // allow for the possiblility of using something other than 1 as // an offset. // // A consequence of being able to change the offset is that you // can break your working code by changing it. So as not plant // time-bombs in the code, never assume you know what the starting // or ending index of a MBTValOrderedOffsetVector is. Instead, // use nGetStartIndex() and nGetEndIndex() for iterating your way // through the array. // // now derived via MBTValOrderedSwapVector, which adds // member function reverseElementOrder() used in complementation // of sequences. chrisa 30-jun-95 // #ifndef MBT_VAL_ORD_OFF_VEC_INCLUDED #define MBT_VAL_ORD_OFF_VEC_INCLUDED #include using namespace std; #include "rwtvalorderedvector.h" template class MBTValOrderedOffsetVector : public RWTValOrderedVector{ public: // ctor needed to pass the capacity (if supplied) to base class MBTValOrderedOffsetVector(size_t nCapacity = nInitialRWTValOrderedVectorCapacity ) : RWTValOrderedVector( nCapacity ) {} // returns first valid index inline int nGetStartIndex() const { return 1; } // returns last valid index inline int nGetEndIndex() const { return (RWTValOrderedVector::length() ); } // // those functions passing or returning an index are overloaded // here to insure the offset arithmetic is done first. // copied out of "rwtvalorderedvector.h" and modified. // inline T& operator[](size_t i) { return RWTValOrderedVector::operator[](i - 1 ); } inline T operator[](size_t i) const { return RWTValOrderedVector::operator[](i - 1 ); } T& at(size_t i) { return (*this)[i - 1 ]; } T at(size_t i) const { return (*this)[i - 1 ]; } size_t index(const T& p) const { return (RWTValOrderedVector::index(p) + 1 ) ; } void insertAt(size_t i, const T& p) { RWTValOrderedVector::insertAt(i - 1, p); } T removeAt(size_t i) { return (RWTValOrderedVector::removeAt(i - 1 )); } }; #endif // MBT_VAL_ORD_OFF_VEC_INCLUDED