Skip to content

Commit

Permalink
Deleted previous main. Writing codification func.
Browse files Browse the repository at this point in the history
  • Loading branch information
Baha committed Apr 2, 2012
1 parent b0e8525 commit f5bd816
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
40 changes: 37 additions & 3 deletions hufftree.cpp
Expand Up @@ -12,15 +12,49 @@ bool HuffmanLeaf::isLeaf()

void HuffmanTree::buildHuffmanTree(Source source)
{
symbolList(source.getSymbolList());
// maybe can cause problems with deletion
symbolList = source.getSymbolList();
rootNode = new HuffmanNode();

rootNode->getCodification(symbolList);
}

void HuffmanNode::getCodification(std::list <Symbol> symbolList)
{
std::list <Symbol>::iterator it1 = symbolList.begin();
float minProb = 100.0f;
std::list <Symbol>::iterator it;
std::list <Symbol>::iterator minIt1 = symbolList.begin();
float minProb = symbolList.front().getProbability();

for (it = symbolList.begin(); it != symbolList.end(); it++)
{
if (minProb > (*it).getProbability())
{
minProb = (*it).getProbability();
minIt1 = it;
}
}

// TODO:
// extract first min symbol
Symbol *symbol1 = &(*minIt1);
// delete first min symbol from list
symbolList.erase(minIt1);

// must try until here

/*
minIt1 = symbolList.begin();
minProb = symbolList.front().getProbability();
for (it = symbolList.begin(); it != symbolList.end(); it++)
{
if (minProb > (*it).getProbability())
{
minProb = (*it).getProbability();
minIt1 = it;
}
}
*/


}
7 changes: 0 additions & 7 deletions main.cpp

This file was deleted.

0 comments on commit f5bd816

Please sign in to comment.