Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Get allocator #689

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
27 changes: 27 additions & 0 deletions list/get_allocator.md
Original file line number Diff line number Diff line change
@@ -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<int> 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);
```
3 changes: 0 additions & 3 deletions list/todo.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
flip
~list
pop_back
push_back
get_allocator