Advertisement
sve_vash

Untitled

Jul 9th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "linear_sequence.h"
  3.  
  4. int main() {
  5. LSQ_HandleT handle;
  6. LSQ_IteratorT iter;
  7. int size, el;
  8.  
  9. handle = LSQ_CreateSequence();
  10. LSQ_InsertFrontElement(handle, 33);
  11. LSQ_InsertFrontElement(handle, 32);
  12.  
  13. size = LSQ_GetSize(handle);
  14. printf("%s %d ", "size", size);
  15. printf("%s", "\n");
  16.  
  17. LSQ_DisplaySequence(handle);
  18. printf("%s", "\n");
  19.  
  20. LSQ_InsertRearElement(handle, 20);
  21. LSQ_InsertRearElement(handle, 21);
  22.  
  23.  
  24. size = LSQ_GetSize(handle);
  25. printf("%s %d ", "size", size);
  26. printf("%s", "\n");
  27.  
  28. LSQ_DisplaySequence(handle);
  29. printf("%s", "before deleting rear element\n");
  30.  
  31. LSQ_DeleteRearElement(handle);
  32.  
  33. size = LSQ_GetSize(handle);
  34. printf("%s %d ", "size", size);
  35. printf("%s", "\n");
  36.  
  37. LSQ_DisplaySequence(handle);
  38. printf("%s", "\n");
  39.  
  40. LSQ_DeleteFrontElement(handle);
  41.  
  42. size = LSQ_GetSize(handle);
  43. printf("%s %d ", "size", size);
  44. printf("%s", "\n");
  45.  
  46. LSQ_DisplaySequence(handle);
  47. printf("%s", "\n");
  48.  
  49.  
  50. iter = LSQ_GetElementByIndex(handle, 1);
  51. LSQ_InsertElementBeforeGiven(iter, 76);
  52. size = LSQ_GetSize(handle);
  53. printf("%s %d ", "size", size);
  54. printf("%s", "\n");
  55.  
  56. LSQ_DisplaySequence(handle);
  57. printf("%s", "\n");
  58.  
  59. LSQ_InsertElementBeforeGiven(iter, 54);
  60. LSQ_InsertElementBeforeGiven(iter, 100);
  61. size = LSQ_GetSize(handle);
  62. printf("%s %d ", "size", size);
  63. printf("%s", "\n");
  64.  
  65. LSQ_DisplaySequence(handle);
  66. printf("%s", "\n");
  67.  
  68. LSQ_AdvanceOneElement(iter);
  69. LSQ_AdvanceOneElement(iter);
  70. LSQ_RewindOneElement(iter);
  71. LSQ_DeleteGivenElement(iter);
  72. size = LSQ_GetSize(handle);
  73. printf("%s %d ", "size", size);
  74. printf("%s", "\n");
  75.  
  76. LSQ_DisplaySequence(handle);
  77. printf("%s", "\n");
  78.  
  79. LSQ_ShiftPosition(iter, 1);
  80. LSQ_InsertElementBeforeGiven(iter, 0);
  81. size = LSQ_GetSize(handle);
  82. printf("%s %d ", "size", size);
  83. printf("%s", "\n");
  84.  
  85. LSQ_DisplaySequence(handle);
  86. printf("%s", "\n");
  87.  
  88. LSQ_DestroyIterator(iter);
  89. iter = LSQ_GetPastRearElement(handle);
  90. if(LSQ_IsIteratorPastRear(iter)) {
  91. printf("%s", "iterator past rear\n");
  92. }
  93.  
  94.  
  95. LSQ_DestroyIterator(iter);
  96. iter = LSQ_GetFrontElement(handle);
  97. LSQ_RewindOneElement(iter);
  98. if(LSQ_IsIteratorBeforeFirst(iter)) {
  99. printf("%s", "iterator before first\n");
  100. }
  101. if(LSQ_IsIteratorDereferencable(iter)) {
  102. printf("%s", "iterator dereferencable");
  103. }
  104.  
  105. return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement