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

Extent.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 University of Massachusetts.  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.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010  */
00011 
00012 
00013 //
00014 // Extent
00015 //
00016 // 11 February 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_EXTENT_HPP
00020 #define INDRI_EXTENT_HPP
00021 #include "lemur-platform.h"
00022 namespace indri
00023 {
00024   namespace index
00025   {
00026     
00027     struct Extent {
00028       double weight;
00029       int begin;
00030       int end;
00031       int ordinal;
00032       int parent;
00033       UINT64 number;
00034 
00035       Extent() : weight(1), begin(-1), end(-1), ordinal(0), parent(-1), number(0) {}
00036       Extent( int b, int e ) : weight(1), begin(b), end(e), ordinal(0), parent(-1), number(0) {}
00037       Extent( int b, int e, int o ) : weight(1), begin(b), end(e), ordinal(o), parent(-1), number(0) {}
00038       Extent( int b, int e, int o, int p ) : weight(1), begin(b), end(e), ordinal(o), parent(p), number(0) {}
00039       Extent( int b, int e, int o, int p, UINT64 n ) : weight(1), begin(b), end(e), ordinal(o), parent(p), number(n) {}
00040       Extent( double w, int b, int e ) : weight(w), begin(b), end(e), ordinal(0), parent(-1), number(0) {}
00041       Extent( double w, int b, int e, int o) : weight(w), begin(b), end(e), ordinal(o), parent(-1), number(0) {}
00042       Extent( double w, int b, int e, int o, int p) : weight(w), begin(b), end(e), ordinal(o), parent(p), number(0) {}
00043       Extent( double w, int b, int e, int o, int p, UINT64 n) : weight(w), begin(b), end(e), ordinal(o), parent(p), number(n) {}
00044 
00045       Extent(const Extent &e) {
00046         weight = e.weight;
00047         begin = e.begin;
00048         end = e.end;
00049         ordinal = e.ordinal;
00050         parent = e.parent;
00051         number = e.number;
00052       }
00053     
00054       bool contains( const Extent& other ) const {
00055         return begin <= other.begin && end >= other.end;
00056       }
00057 
00058       bool before( const Extent& other ) const {
00059         return end <= other.begin;
00060       }
00061 
00062       bool beginsBefore( const Extent& other ) const {
00063         return begin < other.begin;
00064       }
00065 
00066       struct begins_before_less {
00067         bool operator() ( const Extent& one, const Extent& two ) const {
00068           return one.beginsBefore( two );
00069         }
00070       };
00071       
00072       struct ends_before_less {
00073         bool operator() ( const Extent& one, const Extent& two ) const {
00074           if ( one.end < two.end ) {
00075             return true;
00076           } else if ( one.end == two.end ) {
00077             if ( one.begin < two.begin ) {
00078               return true;
00079             } else if ( one.begin == two.begin ) {
00080               if (one.ordinal < two.ordinal ) {
00081                 return true;
00082               } else if ( one.ordinal == two.ordinal ) {
00083                 if ( one.weight < two.weight ) {
00084                   return true;
00085                 }
00086               } 
00087             }
00088           }
00089           return false;
00090         }       
00091       };
00092 
00093       struct ends_before_greater {
00094         bool operator() ( const Extent& one, const Extent& two ) const {
00095           if ( one.end > two.end ) {
00096             return true;
00097           } else if ( one.end == two.end ) {
00098             if ( one.begin < two.begin ) {
00099               return true;
00100             } else if ( one.begin == two.begin ) {
00101               if (one.ordinal < two.ordinal ) {
00102                 return true;
00103               } else if ( one.ordinal == two.ordinal ) {
00104                 if ( one.weight < two.weight ) {
00105                   return true;
00106                 }
00107               } 
00108             }
00109           }
00110           return false;
00111         }       
00112       };
00113 
00114       struct begins_before_ends_before_less {
00115         bool operator() ( const Extent& one, const Extent& two ) const {
00116           if ( one.beginsBefore( two ) )
00117             return true;
00118           else if ( one.begin == two.begin && one.end < two.end ) 
00119             return true;
00120           else if ( one.begin == two.begin && one.end == two.end && one.ordinal < two.ordinal )
00121             return true;
00122           
00123           return false;
00124         }
00125       };
00126     };
00127   }
00128 }
00129 
00130 #endif // INDRI_EXTENT_HPP

Generated on Tue Jun 15 11:02:53 2010 for Lemur by doxygen 1.3.4