From 813d70269073875cd512d8919112346176732c94 Mon Sep 17 00:00:00 2001 From: jiri Date: Sun, 2 Apr 2006 20:48:48 +0000 Subject: [PATCH] *** empty log message *** --- fourindex.h | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/fourindex.h b/fourindex.h index edb6c0d..0012ebf 100644 --- a/fourindex.h +++ b/fourindex.h @@ -141,7 +141,7 @@ public: inline I size() const {return nn;} void resize(const I n); void copyonwrite(); - int length() const; + unsigned long length() const; inline void add(const I i, const I j, const I k, const I l, const T elem) {matel4 *ltmp= new matel4; ltmp->next=list; list=ltmp; list->index.indiv.i=i;list->index.indiv.j=j;list->index.indiv.k=k;list->index.indiv.l=l; list->elem=elem;} @@ -150,12 +150,44 @@ public: inline void add(const I (&index)[4], const T elem) {matel4 *ltmp= new matel4; ltmp->next=list; list=ltmp; memcpy(&list->index.packed, &index, sizeof(union packed_index)); list->elem=elem;} - - - + unsigned long put(int fd) const; + unsigned long get(int fd); }; +//and a class for accessing a disc-stored fourindex + + +/////////////////////////////implementations/////////////////////////////////// + +template +unsigned long fourindex::put(int fd) const +{ +unsigned long n=0; +matel4 *l=list; +matel4stored buf; +while(l) + { + ++n; + buf.elem= l->elem; + buf.dindex= l->index; + if(sizeof(buf)!=write(fd,buf,sizeof(buf))) la_error("write error in fourindex::put"); + l=l->next; + } +return n; +} + + +template +unsigned long fourindex::get(int fd) +{ +unsigned long n=0; +matel4stored buf; +while(sizeof(buf)==read(fd,buf,sizeof(buf))) {++n; add(buf.index,buf.elem);} +return n; +} + + //destructor template fourindex::~fourindex() @@ -285,9 +317,9 @@ void fourindex::copyonwrite() } template -int fourindex::length() const +unsigned long fourindex::length() const { -int n=0; +unsigned long n=0; matel4 *l=list; while(l) {