Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### `insert(char c, iterator i)`
- ```
- increment size private data member by 1
- follow i's current
- check if the length of that chunk is less than chunksize
- follow pointer to chunk current
- use index of char position private data member to get current char position
- use loop starting at the length + 1 position down to the iterator i position data member
- copy the index th character into the index+1 th position
- increment length of the chunk by 1
- set iterator i = char c
- else
- create new chunk
- follow current pointer to chunk
- go the length element and save it to a char variable
- follow pointer to chunk current
- use index of char position private data member to get current char position
- use loop starting at the length + 1 position down to the iterator i position data member
- copy the index th character into the index+1 th position
- increment length of the chunk by 1
- set iterator i = char c
- set the first thing of the newly created chunk to the saved char variable
- loop through while length / chunksize of the new chunk is not less than utilization ratio (1/2)
- get the last element of the original chunk and insert at the first element the new chunk
- decrement size of the original chunk by one
- ```
- #### `erase(iterator i)`
- ```
- (Move-forward method for utilization)
- Decrement size private data member by 1
- Follow i's current
- Check if the length of that chunk is greater than 1
- Follow pointer to chunk current
- Use index of char position private data member to get current char position
- Use loop starting at the above position up to but not including the data member at position length of the chunk
- Copy the index+1th character into the indexth position
- Decrement length of the chunk by 1
- if previous chunk exists
- 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
- get the last element of the previous chunk and insert at the first element the new chunk
- decrement size of the original chunk by one
- else
- Set previous chunk's next iterator to the next of current
- Set the next chunk's previous to the previous of current
- Delete current
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement