Advertisement
eric11144

container.c

Jan 23rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <iostream>
  5.  
  6. #include <vector>
  7.  
  8. #include "push.h"
  9.  
  10. using namespace std;
  11.  
  12. void
  13. init(container_t *sptr)
  14. {
  15.  
  16. }
  17.  
  18. void
  19. container_insert(container_t *sptr,
  20. char c)
  21. {
  22. assert(sptr != NULL && "NULL pointer exception");
  23.  
  24. container_t *newNode = sptr;
  25.  
  26. newNode->container.push_back(c);
  27. }
  28.  
  29. void
  30. container_printlist(container_t *sptr)
  31. {
  32. vector<char>::iterator itr;
  33.  
  34. container_t *cur = sptr;
  35.  
  36. for(itr = cur->container.begin(); itr != cur->container.end(); itr++)
  37. cout << *itr << ' ';
  38. cout << '\n';
  39. }
  40.  
  41. char
  42. container_all_delete(container_t *sptr)
  43. {
  44. container_t *cur = sptr;
  45.  
  46. cur->container.erase(cur->container.begin(), cur->container.end());
  47.  
  48. if(cur->container.empty())
  49. printf("Is empty\n");
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement