Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

IndexedReal.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.cs.cmu.edu/~lemur/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 #ifndef _INDEXEDREAL_HPP
00014 #define _INDEXEDREAL_HPP
00015 
00017 
00030 // CLASSES: IndexedReal, IndexedRealVector (C. Zhai, 12/1/2000)
00031 
00032 #include "common_headers.hpp"
00033 #include <algorithm>
00034 
00035 struct IndexedReal {
00036   int ind;
00037   double val;
00038 };
00039 
00040 
00041 class IndexedRealVector : public vector<IndexedReal> {
00042 public:
00043   
00044   IndexedRealVector() : vector<IndexedReal>() {}
00045   IndexedRealVector(int size) : vector<IndexedReal>(size) {}
00046   virtual ~IndexedRealVector() {}
00047   virtual iterator FindByIndex(int index);
00048 
00050   // return true iff the entry already exists.
00051   virtual bool IncreaseValueFor(int index, double value);
00052 
00054   virtual void PushValue(int index, double value);
00055 
00057   virtual void Sort(bool descending = true);
00058 private:
00059 
00062 
00063   class IndexedRealAscending {
00064   public:
00065     bool operator()(const IndexedReal & a, const IndexedReal & b) {
00066       return a.val < b.val;  // based on the real value
00067     }
00068   };
00069 
00070   class IndexedRealDescending { 
00071   public: 
00072     bool operator()(const IndexedReal & a, const IndexedReal & b) {
00073       return a.val > b.val;  // based on the real value
00074     }
00075   };
00076 
00077   static IndexedRealAscending ascendOrder;
00078   static IndexedRealDescending descendOrder;
00079 
00080 };
00081 
00082 
00083 
00084 #endif //_INDEXEDREAL_HPP
00085 
00086 
00087   
00088 
00089 

Generated at Fri Jul 26 18:22:26 2002 for LEMUR by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000