// IAPS - Image analysis program system // // File name : exIndex.cc // Description: an example of indexed access // Last change: 26.01.1997 // Author : Radek Marik // ----------------------------------------------------------------------- // // // Modifications: // // // // #include "amma/EntryPnt.hh" #include "amma/StdStrm.hh" #include "amma/StdType.hh" #include "amma/Index.hh" // Class AccessC enables to use class IndexC as normal index for // arrays of objects which do not conform IndexC interface. Therefore // it is not necessary to call the member function IndexC::V(). template struct AccessC { AccessC(DataC * p) :ptr(p) {} DataC & operator[](IndexC & i) { return ptr[i.V()];} DataC * ptr; }; int ExIndex(int, char * [] ) //====================== { coutAMMA << "Index access example\n" << "====================\n"; CharT buffer[] = "absdefghijklmnopqrstuvwxyz\n"; AccessC acc(buffer); MIndexT mi = 2; // a machine oriented index IndexC i = mi; // an index with a proper arithmetic operations coutAMMA << "Buffer[2]: " << buffer[mi] << " == " << acc[i] << '\n'; coutAMMA << "End of the example\n"; return 0; } AMMA_ENTRY_POINT(ExIndex) // IAPS - Image analysis program system. // End of file exBfAcc.cc