Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/ecole_etude_fac_de_pau/licence_3/projet_lzw/include/deflater.h

(Deskargatu)

/*
    This file is part of projet_lzw_univ_pau.

    projet_lzw_univ_pau is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    projet_lzw_univ_pau is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with projet_lzw_univ_pau; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


#ifndef _LZW_de
#define _LZW_de
#include <map>
#include <vector>

/*
     Classe Deflater
	- Utilisation priviliegiee d'un tableau de chars:
	si l'on compresse un fichier binaire contenant le caractere ascii nul '\0'
	on aura alors une fin de string non justifiee...
	- Utilisation d'un tableau associatif pour le dictionnaire: rapidite de la 
	fonction de recherche en O(ln).
*/



class Deflater {
    public:
	Deflater();
	int deflate(int);    
	/* use of defate: 
	   0 = add packet and wait for more , 
	   1 = finish the current buffer
	*/

	void setInput(std::vector<char>&);
	int needInput(); // fonction non utilisee (ennonce)
	std::vector<unsigned  int> compression; // Buffer de sortie
	float compression_ratio;    // Taux de compression pour le buffer en cours
    
    private:
	std::vector<char> buffer; // Buffer a compresser
	std::map<const std::vector<char>,unsigned  int> dico; // Dictionnaire de mots
	void add_word(const std::vector<char>&); // Ajout d un mot dans le dico
	int find_word(const std::vector<char>&); // Trouve un mot dans le dico

	unsigned  int valeur_max; // Variable indice du dictionnaire
	
};


#endif