Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxIndxArray.h

00001 /*
00002  *  Copyright (c) 2000, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jan-Mark Geusebroek (mark@wins.uva.nl)
00007  *
00008  */
00009 
00010 #ifndef HxIndxArray_H
00011 #define HxIndxArray_H
00012 
00013 #include <stdio.h>
00014 #include <list>
00015 #include "HxMatrix.h"
00016 
00017 
00018 template<class ArrayT, class HeaderT>
00019 class indexedArray {
00020 public:
00021     indexedArray();
00022     ~indexedArray();
00023 
00024     void open(HxString indexFile, int norm = 0);
00025     void append(HxString indexFile);
00026     void create(HxString indexFile);
00027     void setHeader(HeaderT& header)
00028         {_header = header;}
00029         // should be called after create, before the first add
00030 
00031     HeaderT     header() const {return _header;}
00032 
00033     int         size() const {return _key.size();}
00034 
00035     virtual int arraySize(const HeaderT& header) const = 0;
00036     virtual double compare(ArrayT *e1, ArrayT *e2,
00037         const HeaderT& header) const = 0;
00038 
00039     void        add(HxString& key, ArrayT *data);
00040 
00041     void        random(int n);
00042     void        search(ArrayT *target, int n, int refine = 0);
00043     HxString    nearest(int n) const;
00044     double      score(int n) const;
00045     ArrayT*     nearestData(int n) const;
00046 
00047     HxMatrix    similarity() const;
00048     STD_OSTREAM& put(STD_OSTREAM& os) const;
00049 
00050     void        import(STD_ISTREAM& is);
00051 
00052     friend STD_OSTREAM& operator<<(STD_OSTREAM& os,
00053             const indexedArray<ArrayT, HeaderT>& l)
00054                 {return l.put(os);}
00055 
00056 
00057 private:
00058     HeaderT     _header;
00059     HxString     _fileName;
00060 
00061     FILE        *_fp;
00062     char        *_mem;
00063 
00064     int         _arraySize;
00065 
00066     std::list<ArrayT*>   _arrays;
00067     std::list<char*>        _key;
00068 
00069     double      *_nearval;
00070     char        **_nearkey;
00071     ArrayT      **_neardata;
00072 
00073     int         _normalize;
00074     ArrayT      *_minVal;
00075     ArrayT      *_normVal;
00076 };
00077 
00078 #ifdef INC_TEMPLATE_SRC
00079 #include "HxIndxArray.c"
00080 #endif
00081 
00082 #endif

Generated on Tue Jan 8 13:59:14 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001