#include "MoveList.h" MoveList::MoveList():allocated_length(1), length(0) { list = new Move(); } MoveList::MoveList(int l):allocated_length(l), length(0) { list = new Move[l]; } MoveList::MoveList(const MoveList &otherList):length(otherList.length), allocated_length(otherList.allocated_length) { int i; list = new Move[otherList.allocated_length]; for (i=0; i< otherList.length; i++) { list[i] = otherList.list[i]; } } int MoveList::getLength() { return length; } Move MoveList::move(int n) { return list[n]; } void MoveList::add(int n, Move m) { int i; if (n >= allocated_length || n < 0) return; length++; for( i = length; i > n; i--) { list[i]=list[i-1]; } list[n] = m; //Need to add the functionality of increasing the array size, in case //of going over the bounds. } void MoveList::add(Move m) { add(length, m); } void MoveList::remove(int n) { int i; if (n >= length || n < 0) return; length--; for( i = n; i < length; i++) { list[i]=list[i+1]; } } void MoveList::remove(Move m) { int i; int n = -1; for( i = 0; i < length; i++) { if (list[i] == m) { n = i; break; } } if (n >= length || n < 0) return; length--; for( i = n; i < length; i++) { list[i]=list[i+1]; } }