Пример #1
0
void CModel::DeleteSequence(CSequence* deleteSequence)
{
	// linklist is only 1-way, so we need to find the stage previous to this (if any)...

	CSequence* prevSequence = NULL;
	CSequence* scanSequence = GetFirstSequence();

	while (scanSequence && scanSequence != deleteSequence)
	{
		prevSequence = scanSequence;
		scanSequence = scanSequence->GetNext();
	}
	if (scanSequence == deleteSequence)
	{
		// we found it, so was this the first sequence in the list?

		if (prevSequence)
		{
			prevSequence->SetNext(scanSequence->GetNext());	// ...no
		}
		else
		{
			m_sequences = scanSequence->GetNext();			// ...yes
		}
		scanSequence->Delete();
	}
}
Пример #2
0
void CModel::ReOrderSequences()
{
	typedef vector<CSequence*> sequences_t; sequences_t sequences;

	// add sequences to list...

	CSequence *curSequence = m_sequences;
	while (curSequence)
	{
		sequences.push_back(curSequence);
		curSequence = curSequence->GetNext();
	}

	// re-order sequences...

	qsort( (void *)&sequences[0], (size_t)(sequences.size()), sizeof(CSequence *), ModelSequenceCompareFunc );

	// now rebuild links...

	int iTotMasterSequences = GetTotMasterSequences();	// this needs to be eval'd here, you can't do it in the for-next below
	m_sequences = NULL;
	for (int i=0; i<iTotMasterSequences; i++)
	{
		curSequence = sequences[i];
		curSequence->SetNext(NULL);

		AddSequence(curSequence);
	}

	Resequence();
}
Пример #3
0
void CModel::AddSequence(CSequence* sequence)
{
	if (m_sequences == NULL)
	{
		m_sequences = sequence;
	}
	else
	{
		CSequence* curSequence = m_sequences;
		while(curSequence->GetNext() != NULL)
		{
			curSequence = curSequence->GetNext();
		}
		curSequence->SetNext(sequence);
	}
}