BlocoRedundancia.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package cache;
  7. /**
  8. *
  9. * @author Juninho Carlos
  10. */
  11. public class BlocoRedundancia{
  12. private PalavrasRedundancia[] palavras;
  13. public BlocoRedundancia(){
  14. this.palavras = new PalavrasRedundancia[32];
  15. for(int i = 0 ; i < 32; i++){
  16. this.palavras[i] = new PalavrasRedundancia();
  17. }
  18. }
  19. public void leituraEspecialNoBloco(int tag){
  20. for(int i = 0; i < 32; i++){
  21. this.palavras[i].leituraEspecial(tag);
  22. }
  23. }
  24. public PalavrasRedundancia getPalavra(int index){
  25. return this.palavras[index];
  26. }
  27. public PalavrasRedundancia[] getPalavras(){
  28. return this.palavras;
  29. }
  30. public int getTagFromAWord(int palavra){
  31. return this.palavras[palavra].getTag();
  32. }
  33. public void writeAWord(int palavra,int tag){
  34. this.palavras[palavra].writeAWord(tag);
  35. }
  36. @Override
  37. public String toString() {
  38. String s = "";
  39. int i = 0;
  40. for (PalavrasRedundancia palavra : palavras) {
  41. s += i + " - " + palavra.isValid()+ " "+ palavra.getTag()+"\n";
  42. i++;
  43. }
  44. return s; //To change body of generated methods, choose Tools | Templates.
  45. }
  46. }