diff --git a/list/README.md b/list/README.md index 03e34cd4..ff04c346 100644 --- a/list/README.md +++ b/list/README.md @@ -13,10 +13,13 @@ :heavy_check_mark: [end](end.md) :heavy_check_mark: [erase](erase.md) :heavy_check_mark: [front](front.md) +:heavy_check_mark: [get_allocator](get_allocator.md) :heavy_check_mark: [insert](insert.md) :heavy_check_mark: [max_size](max_size.md) :heavy_check_mark: [merge](merge.md) +:heavy_check_mark: [pop_back](pop_back.md) :heavy_check_mark: [pop_front](pop_front.md) +:heavy_check_mark: [push_back](push_back.md) :heavy_check_mark: [rbegin](rbegin.md) :heavy_check_mark: [remove](remove.md) :heavy_check_mark: [rend](rend.md) @@ -28,7 +31,4 @@ :heavy_check_mark: [swap](swap.md) :heavy_check_mark: [unique](unique.md) :x: flip -:x: get_allocator -:x: pop_back -:x: push_back :x: ~list diff --git a/list/get_allocator.md b/list/get_allocator.md new file mode 100644 index 00000000..f5c5e0c6 --- /dev/null +++ b/list/get_allocator.md @@ -0,0 +1,27 @@ +**Description**: list::get_allocator() returns a copy of the allocator object associated with the list container. + +**Example**: + +```cpp + //Declare new list: + std::list List1; + + //Declare a new int pointer: + int * pntr; + + //Allocate an array of 2 elements using our list allocator: + pntr = List1.get_allocator().allocate(2); + + //Input elements to array: + for(int i = 0; i < List1.size(); ++i) std::cin >> pntr[i]; + + std::cout << "List1 contains: " + //Print elements of the array: + for(int i = 0; i < List1.size(); ++i){ + std::cout << ' ' << pntr[i]; + } + std::cout << std::endl; + + //Deallocate the memory used to the array: + List1.get_allocator().deallocate(p,2); +``` diff --git a/list/todo.txt b/list/todo.txt index 5b657012..b3e6455d 100644 --- a/list/todo.txt +++ b/list/todo.txt @@ -1,5 +1,2 @@ flip ~list -pop_back -push_back -get_allocator \ No newline at end of file