11719 - Implement a list 6 (operator new)   

Description

You must follow the rules as below:

1. do not use any static variables

2. do not use any variables which is not inside a function

3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory

4. memory usage limit: 16384 byte

You are required to implement a list.

You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")

If you don't know what operator new is, check 11419 - Using your vector​.

Input

The input consist of a number of operations. Each operations (copy ctor, copy assign, back, front, clear, erase, insert and show) are separated by a newline character ('\n').

Operation copy ctor: following by a non-negative integer (which list calls the copy constructor).

Operation copy assign: following by a non-negative integer (which list calls the copy assignment operator).

Operation back: Print the value of last node.

Operation front: Print the value of first node.

Operation clear: Erase all nodes.

Operation erase: following by a non-negative integer (erase position). Erase a node at erase position.

Operation insert: following by a non-negative integer (insert position) and a string. Insert a node at insert position with inserted string.

Operation show: print the value of all nodes in the list. Print a whitespace character (' ') after printing the value of nodes. If the list is empty, do not print anything.

Output

Implement List (constructor, copy constructor, copy assignment operator, destructor, back, front, clear, erase and insert) and operator<<(std::ostream &os,const List &lst).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11719.cpp

Partial Judge Header

11719.h

Tags




Discuss