// // Programmer: Craig Stuart Sapp // Creation Date: Sat Nov 8 17:33:48 GMT-0800 1997 // Last Modified: Sat Nov 8 19:33:17 GMT-0800 1997 // Filename: ...sig/maint/code/base/LookupTable/LookupTableCI/LookupTableCI.cpp // Web Address: http://sig.sapp.org/src/sigBase/LookupTableCI.cpp // Documentation: http://sig.sapp.org/doc/classes/LookupTable // Syntax: C++ // #include "LookupTableCI.h" #include #ifndef OLDCPP #include using namespace std; #else #include #endif ////////////////////////////// // // LookupTableCI::LookupTableCI -- // default value: size = 0 // LookupTableCI::LookupTableCI(int size) { if (size < 0) { cerr << "Error in creating LookupTableCI: " << "table size cannot be negative: " << size << endl; exit(1); } maxSize = size; if (size > 0) { tableData = new sampleType[maxSize]; } else { tableData = NULL; } borrowTableQ = 0; // Not borrowing a table; } LookupTableCI::LookupTableCI(sampleType* borrowedTable, int size) { if (size < 0) { cerr << "Error: table size cannot be negative: " << size << endl; exit(1); } maxSize = size; tableData = borrowedTable; borrowTableQ = 1; // borrowing a table; } LookupTableCI::LookupTableCI(LookupTableCI& aTable) { maxSize = aTable.maxSize; borrowTableQ = aTable.borrowTableQ; if (!borrowQ()) { // internal table if (maxSize == 0) { tableData = NULL; } else { tableData = new sampleType[maxSize]; for (int i=0; i= maxSize) { cerr << "Error invalid array acces in LookupTable: " << index << endl; } return tableData[index]; } sampleType LookupTableCI::readf(double index) const { // constant interpolation, ignore fractional value of index return tableData[(long)index]; } // md5sum: 492b62ea1c917faa1b460c2985d5764b LookupTableCI.cpp [20050403]