1314 - CS I2P (II) 2017-2 Lee HW5 Scoreboard

Time

2017/11/14 12:00:00 2018/01/15 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11445 Copy a vector (Implement a vector 6)

11445 - Copy a vector (Implement a vector 6)   

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: 9216 byte

You are required to implement a vector.

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

Input

There are seven functions in Vector that you have to implement, the functionality is as below:

  • default constructor: initializes pointers. Do not allocate memory.
  • copy constructor: copys the elements of rhs. The new capacity is rhs.size().
  • copy assignment operator: copys the elements of rhs. The new capacity is rhs.size().
  • erase: erases a element at pos.
  • insert: inserts a val at pos. When capacity is not enough, the new capacity is max(old capacity + 1, old capacity * 3).
  • reserve: reserves storage (Increase the capacity of the container to a value that's equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.).
  • destructor

Output

Complete a Vector (default constructor, copy constructor, copy assignment operator, erase, insert, reserve and destructor).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11445.cpp

Partial Judge Header

11445.h

Tags




Discuss