/* * hringir.h * Rings (Directed Cyclical Graphs) Class * v.1.0 * * Copyright Casady Kemper March 28 2009. * * Permission to use, copy, modify, distribute and sell this software * and its documentation (where applicable) for any purpose is hereby * granted without fee, provided that the above copyright notice appear * in all copies and that both that copyright notice and this permission * notice appear in supporting documentation. * */ template class ring { public: ring(int len); ~ring(); efni &operator[](int n); const efni &operator[](int n) const; int length; private: efni *index; }; template ring::ring(int len){ index = new efni[len]; length = len; } template ring::~ring(){ delete [] index; } template efni &ring::operator[](int n) { n%=length; if(n<0){ n+=length; } return index[n]; } template const efni &ring::operator[](int n) const { n%=length; if(n<0){ n+=length; } return index[n]; }