Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1.17 KB

File metadata and controls

45 lines (34 loc) · 1.17 KB

Dynamic_Array_Allocation_with_Push_Delete

C++ Program Implementing Dynamic Array Features

the task which i implemented

General C++ Test

Description

Design a templated, dynamically-growing array. The interface should at least have these procedures:

  • push_back
    Add an element to the end of the array
  • operator[]
    Access specified element with bounds checking
  • remove_if
    Take a predicate and remove all elements which satisfy that predicate (i.e. when predicate is true)

Implementation should not have memory leaks. Feel free to add more capabilities to the interface if you need to.

Pseudo Usage

// Assume array is of type Item_Type and empty
// content: {}

array.push_back(item_0);
array.push_back(item_1);
array.push_back(item_2);
array.push_back(item_3);
// content: {item_0, item_1, item_2, item_3}

auto item = arr[2];
// item now contains item_2

// remove any element that is not item_3
arr.remove_if(
	[](Item_Type item) {
		return item != item_3;
	}
);
// content: {item_3}

Submission

A single C++ file (test.cpp) that contains the implementation of the array and a main function that demonstrates the usage of its interface.