words__tools.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # include "words.h"
  2. /* FILE
  3. *
  4. * file: words.cpp
  5. *
  6. *
  7. */
  8. /*
  9. */
  10. /* INFO del (WithSelect _)
  11. *
  12. * remove the preselected item - from the selected point (select)
  13. *
  14. * return: void
  15. *
  16. *
  17. */
  18. void
  19. words__del (struct Words *this)
  20. {
  21. /* IF this->select->prev is not NULL */
  22. if (this->select->previous != NULL)
  23. {
  24. this->select->previous->next = this->select->next;
  25. }
  26. else /* */
  27. {
  28. /* this->select->next will be first */
  29. this->head = this->select->next;
  30. }
  31. /* IF this->select->next is not NULL */
  32. if (this->select->next != NULL)
  33. {
  34. this->select->next->previous = this->select->previous;
  35. }
  36. else /* else IF this->select->next is NULL */
  37. {
  38. /* this->select->prev will be last */
  39. this->tail = this->select->previous;
  40. }
  41. clear__str (this->select->value);
  42. delete this->select;
  43. }
  44. void
  45. clear__str (char *value)
  46. {
  47. }
  48. struct Word*
  49. words__get(struct Words *this)
  50. {
  51. return this->select;
  52. }
  53. /* INFO del (WithTail _)
  54. *
  55. * remove the last element - from the tail part (tail)
  56. *
  57. * return: this->tail element
  58. *
  59. *
  60. */
  61. void
  62. del__tail (struct Words *this)
  63. {
  64. this->tail->previous->next = NULL;
  65. this->tail->value->clear ();
  66. remove = this->tail;
  67. this->tail = this->tail->previous;
  68. delete remove;
  69. }
  70. /* INFO del (WithHead _)
  71. *
  72. * remove the first element - from the head part (head)
  73. *
  74. * return: this->head element
  75. *
  76. *
  77. */
  78. void
  79. del__head (struct Words *this)
  80. {
  81. this->head->next->previous = NULL;
  82. this->head->value->clear ();
  83. Word* remove = this->head;
  84. this->head = this->head->next;
  85. delete remove;
  86. }