From 744733f2b2519a004913fcc2ba57d00e526f976d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n?= Date: Sat, 8 Oct 2022 19:01:34 +0200 Subject: [PATCH 1/7] Added list get_allocator() --- get_allocator.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 get_allocator.md diff --git a/get_allocator.md b/get_allocator.md new file mode 100644 index 00000000..420dde21 --- /dev/null +++ b/get_allocator.md @@ -0,0 +1,26 @@ +/_ +Author : Pequicu1 +Date : 08/10/2022 +Time : 18:42 +Description : list::get_allocator() returns a copy of the allocator object associated with the list container. +_/ + +//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); + +for(int i = 0; i < List1.size(); ++i) std::cin >> p[i]; + +std::cout << "List1 contains: " +for(int i = 0; i < List1.size(); ++i){ +std::cout << ' ' << p[i]; +} +std::cout << std::endl; + +//Deallocate the memory used to the array: +mylist.get_allocator().deallocate(p,2); From 3f2dfc6dd15d203becd151fed699655d7e82f380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n?= Date: Sat, 8 Oct 2022 19:14:21 +0200 Subject: [PATCH 2/7] Added list get_allocator() --- list/get_allocator.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 list/get_allocator.md diff --git a/list/get_allocator.md b/list/get_allocator.md new file mode 100644 index 00000000..d48f5307 --- /dev/null +++ b/list/get_allocator.md @@ -0,0 +1,30 @@ +/_ +Author : Pequicu1 +Date : 08/10/2022 +Time : 19:10 +**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); + + for(int i = 0; i < List1.size(); ++i) std::cin >> pntr[i]; + + std::cout << "List1 contains: " + 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); +``` From 0b3fea0c3ade872a2c36e122a61465c84ff6872e Mon Sep 17 00:00:00 2001 From: Pequicu1 <46902665+Pequicu1@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:17:10 +0200 Subject: [PATCH 3/7] Delete get_allocator.md --- get_allocator.md | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 get_allocator.md diff --git a/get_allocator.md b/get_allocator.md deleted file mode 100644 index 420dde21..00000000 --- a/get_allocator.md +++ /dev/null @@ -1,26 +0,0 @@ -/_ -Author : Pequicu1 -Date : 08/10/2022 -Time : 18:42 -Description : list::get_allocator() returns a copy of the allocator object associated with the list container. -_/ - -//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); - -for(int i = 0; i < List1.size(); ++i) std::cin >> p[i]; - -std::cout << "List1 contains: " -for(int i = 0; i < List1.size(); ++i){ -std::cout << ' ' << p[i]; -} -std::cout << std::endl; - -//Deallocate the memory used to the array: -mylist.get_allocator().deallocate(p,2); From 87836d4f6164f15f3819d2180183c83cc25a97e8 Mon Sep 17 00:00:00 2001 From: Pequicu1 <46902665+Pequicu1@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:33:09 +0200 Subject: [PATCH 4/7] get_allocator() --- list/get_allocator.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/list/get_allocator.md b/list/get_allocator.md index d48f5307..f5c5e0c6 100644 --- a/list/get_allocator.md +++ b/list/get_allocator.md @@ -1,25 +1,22 @@ -/_ -Author : Pequicu1 -Date : 08/10/2022 -Time : 19:10 **Description**: list::get_allocator() returns a copy of the allocator object associated with the list container. -_/ **Example**: ```cpp - //Declare new list + //Declare new list: std::list List1; - //Declare a new int pointer + //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]; } From 39a3dd6e96817c461dded2a62d499f325e27ab52 Mon Sep 17 00:00:00 2001 From: Pequicu1 <46902665+Pequicu1@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:35:15 +0200 Subject: [PATCH 5/7] Updated todo.txt --- list/todo.txt | 3 --- 1 file changed, 3 deletions(-) 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 From 588a794fe105443ff3288e208d5392e7c5eaba2f Mon Sep 17 00:00:00 2001 From: Pequicu1 <46902665+Pequicu1@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:38:23 +0200 Subject: [PATCH 6/7] Update README.md --- list/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/list/README.md b/list/README.md index 03e34cd4..80b7ee54 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_chech_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 From ab2155b8869deac897e178043df2ca9995f39a0e Mon Sep 17 00:00:00 2001 From: Pequicu1 <46902665+Pequicu1@users.noreply.github.com> Date: Sat, 8 Oct 2022 19:39:06 +0200 Subject: [PATCH 7/7] Update README.md --- list/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list/README.md b/list/README.md index 80b7ee54..ff04c346 100644 --- a/list/README.md +++ b/list/README.md @@ -13,7 +13,7 @@ :heavy_check_mark: [end](end.md) :heavy_check_mark: [erase](erase.md) :heavy_check_mark: [front](front.md) -:heavy_chech_mark: [get_allocator](get_allocator.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)