/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SORTABLEH #define SORTABLEH #include #include #include //////////////////////////////////////////////////// // // NOTE that these classes are not MT safe: // need to be called from dbamp // struct record_t : public filemap::rec_t { static const int maxtabs=filemap::maxtabs; static const int recsize=(maxtabs+1)*sizeof(long); byte4 pos[maxtabs+1]; char data[sizeof(byte4)]; int size() const { return pos[maxtabs].get()-pos[0].get(); } int size(int i) const { return pos[i+1].get()-pos[i].get(); } sref at(int i) const { return sref(data+pos[i].get(),size(i)); } ///////////////////////////////////////////////// record_t(const record_t& rec) { for(int i=0;i<=maxtabs;i++) pos[i]=rec.pos[i]; memcpy(data,rec.data,rec.caps.get()); } record_t(const spile& list); ///////////////////////////////////////////////// void get(spile& list) const { for(int i=0;icol;i--) pos[i]=pos[i-1]; } void remove(int col) { resize(col,0); for(int i=col;i { public: typedef mrvec::iterator iterator; typedef mrvec::const_iterator const_iterator; struct comp_t { op_t::op2_t func; comp_t() : func(0) {} comp_t(const op_t* op) : func(op->f2) {} bool operator()(const idx_t& a,const idx_t& b) const { int_stream res; op_env env; func(res,env,a.key,b.key); return res.val; } }; int get(const sref& t) const; int add(const sref& t,record_t* rec); void sort(const op_t* op); private: comp_t comp; }; #endif