Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1.  
  2. #### `insert(char c, iterator i)`
  3. ```
  4. increment size private data member by 1
  5. follow i's current
  6. check if the length of that chunk is less than chunksize
  7. follow pointer to chunk current
  8. use index of char position private data member to get current char position
  9. use loop starting at the length + 1 position down to the iterator i position data member
  10. copy the index th character into the index+1 th position
  11. increment length of the chunk by 1
  12. set iterator i = char c
  13. else
  14. create new chunk
  15. follow current pointer to chunk
  16. go the length element and save it to a char variable
  17. follow pointer to chunk current
  18. use index of char position private data member to get current char position
  19. use loop starting at the length + 1 position down to the iterator i position data member
  20. copy the index th character into the index+1 th position
  21. increment length of the chunk by 1
  22. set iterator i = char c
  23. set the first thing of the newly created chunk to the saved char variable
  24. loop through while length / chunksize of the new chunk is not less than utilization ratio (1/2)
  25. get the last element of the original chunk and insert at the first element the new chunk
  26. decrement size of the original chunk by one
  27. ```
  28.  
  29.  
  30. #### `erase(iterator i)`
  31.  
  32. ```
  33. (Move-forward method for utilization)
  34.  
  35. Decrement size private data member by 1
  36. Follow i's current
  37. Check if the length of that chunk is greater than 1
  38. Follow pointer to chunk current
  39. Use index of char position private data member to get current char position
  40. Use loop starting at the above position up to but not including the data member at position length of the chunk
  41. Copy the index+1th character into the indexth position
  42. Decrement length of the chunk by 1
  43. if previous chunk exists
  44. loop through while length / chunksize of the new chunk is not less than utilization ratio (1/4) and length / chunksize of previous chunk is greater than uilization ratio
  45. get the last element of the previous chunk and insert at the first element the new chunk
  46. decrement size of the original chunk by one
  47. else
  48. Set previous chunk's next iterator to the next of current
  49. Set the next chunk's previous to the previous of current
  50. Delete current
  51. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement