Advertisement
Guest User

LineBuffer

a guest
Mar 30th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace WindowsFormsApplication13
  8. {
  9. class Linebuffer
  10. {
  11. // Attribute und Properties
  12. private int[] bufData;
  13. public int this[int a]
  14. {
  15. get
  16. {
  17. return bufData[a];
  18. }
  19. }
  20. private int head;
  21. private bool bufFull;
  22.  
  23. // Methoden
  24. public Linebuffer()
  25. {
  26. bufData = new int[12];
  27. head = -1;
  28. bufFull = false;
  29. }
  30. public Linebuffer(int size)
  31. {
  32. bufData = new int[size];
  33. head = -1;
  34. bufFull = false;
  35. }
  36. public int BufSize()
  37. {
  38. return bufData.Length;
  39. }
  40. public int BufDataLen()
  41. {
  42. int rw = 0;
  43. for (int a = 0; a <= head ; a++)
  44. {
  45. rw++;
  46. }
  47. return rw;
  48. }
  49. public bool BufFull()
  50. {
  51. return bufFull;
  52. }
  53. public void Add(int val)
  54. {
  55. if (head == bufData.Length - 1)
  56. {
  57. head = -1;
  58. bufFull = true;
  59. }
  60. head++;
  61. bufData[head] = val;
  62. }
  63. public void Clear()
  64. {
  65. head = -1;
  66. for (int a = 0; a < bufData.Length; a++)
  67. {
  68. bufData[a] = 0;
  69. }
  70. bufFull = false;
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement