Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SmallRing.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: SmallRing.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.12 $       $Date: 2020/10/28 15:09:57 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * A SmallRing contains an ordered list of atoms which are connected
00019  * to each other to form a loop.  The atom numbers are the
00020  * unique atom numbers as used in BaseMolecule. The ordering of
00021  * the atoms, in addition to specifying how the atoms in the ring are
00022  * connected, also gives the orientation (handedness) of the ring.
00023  *
00024  ***************************************************************************/
00025 #ifndef SMALLRING_H
00026 #define SMALLRING_H
00027 
00028 #include "ResizeArray.h"
00029 #include "Inform.h"
00030 
00037 class SmallRing {
00038 public:
00039   ResizeArray<int> atoms;
00040   short int orientated;
00041   
00042   SmallRing(void) : atoms(1), orientated(0) {}
00043   
00044   int num(void) { return int(atoms.num()); }
00045   int operator [](int i) { return atoms[i]; }
00046   void append(int i) { atoms.append(i); }
00047 
00048   int last_atom(void) { return atoms[atoms.num()-1]; }
00049   int first_atom(void) { return atoms[0]; }
00050   int closed(void) { return first_atom() == last_atom(); }
00051   void remove_last(void) { atoms.truncatelastn(1); }
00052  
00053   void reverse(void) {
00054     ResizeArray<int> atomscopy(atoms.num());
00055     int i, len;
00056     len = int(atoms.num());
00057     
00058     for (i=0;i<len;i++) atomscopy.append(atoms[i]);
00059     atoms.clear();
00060     for (i=len-1;i>=0;i--) atoms.append(atomscopy[i]);
00061   }
00062 
00063   void clear(void) {
00064     atoms.clear();
00065     orientated = 0;
00066   }
00067   
00068   SmallRing* copy(void) {
00069     SmallRing *ringcopy;
00070     int i, len;
00071     
00072     ringcopy = new SmallRing();
00073     len = num();
00074     for (i=0; i < len; i++) ringcopy->append(atoms[i]);
00075     ringcopy->orientated = orientated;
00076     
00077     return ringcopy;
00078   }
00079   
00080   friend Inform& operator << (Inform &os, SmallRing &sr) {
00081     int i, len;
00082     len = sr.num();
00083     
00084     for (i=0; i < len; i++) {
00085         os << sr[i];
00086         if (i == len-1) break;
00087         os << ", ";
00088     }
00089     
00090     return os;
00091   }
00092   
00093 };
00094 
00095 #endif

Generated on Fri Oct 4 02:45:00 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002