Skip to content
Snippets Groups Projects
ISROr.h 1.14 KiB
Newer Older
  • Learn to ignore specific revisions
  • //
    // Created by Jake Close on 3/13/18.
    //
    
    #pragma once
    
    #include "ISR.h"
    
    jsclose's avatar
    jsclose committed
    #include <vector>
    
    jsclose's avatar
    jsclose committed
    using namespace std;
    class ISROr : public ISR
    
    vcday's avatar
    vcday committed
    public:
    
    jsclose's avatar
    jsclose committed
    	vector<ISR*>Terms;
    
    vcday's avatar
    vcday committed
    	unsigned NumberOfTerms;
    
    jsclose's avatar
    jsclose committed
    
    
    	Location First ( ) override;
    	Location Next ( ) override;
    	Location NextDocument ( ) override;
    	Location Seek ( Location target ) override;
    	Location GetEndDocument ( ) override;
    
    
    jsclose's avatar
    jsclose committed
    	Location GetCurrentLocation();
    
    
    vcday's avatar
    vcday committed
    	Location GetStartLocation ( );
    	Location GetEndLocation ( );
    
    jsclose's avatar
    jsclose committed
    
    
    vcday's avatar
    vcday committed
    
    
    jsclose's avatar
    jsclose committed
    	ISROr ( vector<ISR * > InputTerms ) : Terms( InputTerms )
    
    vcday's avatar
    vcday committed
    		{
    
    
    jsclose's avatar
    jsclose committed
    		for(auto currentTerm : InputTerms)
    			{
    
    vcday's avatar
    vcday committed
    			currentTerm->First( );
    			Location currentLocation = currentTerm->currentLocation;
    			if ( currentLocation < nearestStartLocation )
    
    jsclose's avatar
    jsclose committed
    				{
    
    vcday's avatar
    vcday committed
    				nearestTerm = currentTerm;
    				nearestStartLocation = currentLocation;
    
    jsclose's avatar
    jsclose committed
    
    				}
    
    vcday's avatar
    vcday committed
    			if ( currentLocation > nearestEndLocation )
    				{
    				nearestEndLocation = currentLocation;
    				}
    			++NumberOfTerms;
    
    jsclose's avatar
    jsclose committed
    			currentTerm++;
    
    vcday's avatar
    vcday committed
    
    		}
    
    jsclose's avatar
    jsclose committed
    
    
    vcday's avatar
    vcday committed
    		}
    
    jsclose's avatar
    jsclose committed
    
    
    vcday's avatar
    vcday committed
    private:
    	ISR *nearestTerm;
    	// nearStartLocation and nearestEndLocation are// the start and end of the nearestTerm.
    	Location nearestStartLocation, nearestEndLocation;