ChangeSorter.h #4

  • //
  • guest/
  • sam_stafford/
  • p4hl/
  • src/
  • dlls/
  • ChangeSorter.h
  • View
  • Commits
  • Open Download .zip Download (551 B)
#ifndef CHANGESORTER_H
#define CHANGESORTER_H

#include "changenode.h"

class ChangeSorter  
{
public:
	ChangeSorter();
	~ChangeSorter();

	void AddChange(StrBuf); //add a change to the list
	int GetPos(StrBuf);		//get position of a change
	StrBuf GetChange(int);	//get change at a position

	int Size() 
		{return size;}		//total number of changes.

private:
	ChangeNode* head;
	ChangeNode* tail;

	ChangeNode* seek;

	int counter; // the position of seek, min. value 1
	int size; //the total number of nodes in the list
};

#endif // CHANGESORTER_H
# Change User Description Committed
#4 1689 Sam Stafford Integrate 02.1 API and code cleanup to P4HL.
 Lots of work.  Phew.
#3 1548 Sam Stafford Integrate RevType change to make sure it works.
 It does.
#2 1349 Sam Stafford Overhaul to ChangeSorter implementation.
 Member variables of ChangeSorter have
been made private, since nothing was (or should be) accessing them directly, and
methods, which remain public, should look the same from outside.

The original ChangeSorter was quick and dirty because I wanted to see P4HL working
quickly, but it was also about as inefficient as possible because it used single links
and linear searches.

The new and improved ChangeSorter is a doubly-linked list with intelligent searching
that's geared toward sequential access of elements that are close to each other, which
is indeed the nature of most of the queries that P4HL makes.  Even in a worst-case
scenario, this version should perform at least as well as the old one.

No noticeable performance change or bugs as of yet, but in theory we'd see the difference
with really large sets of data (ones larger than P4HL can show us).
#1 937 Sam Stafford Renaming my guest directory to the more conventional
sam_stafford.
//guest/samwise/p4hl/src/dlls/ChangeSorter.h
#1 936 Sam Stafford Adding P4HL to the public depot.
 See relnotes.txt for
installation instructions; all relevant files are under
p4hl/dist.

Source code is under p4hl/src in the form of a VC++ project.