//
//  Map.h
//  Wbl3001
//
//  Created by david van brink on 3/20/13.
//
//

#ifndef Wbl3001_Map_h
#define Wbl3001_Map_h



#include <stdlib.h>
#include "List.h"


template <int S,class A, class B>
class Map
{
public:
    List<S,A> listA;
    List<S,B> listB;
    
    Map()
    {
//        this->listA = new List<A>(maxSize);
//        this->listB = new List<B>(maxSize);
    }
    
    void removeAt(int ix)
    {
        if(ix >= 0)
        {
            this->listA.removeAt(ix);
            this->listB.removeAt(ix);
        }
    }
    
    void put(A a,B b)
    {
        int ix = this->listA.find(a);
        this->removeAt(ix);
        ix = this->listB.find(b);
        this->removeAt(ix);
        
        this->listA.add(a);
        this->listB.add(b);
    }
    
    B get(A a)
    {
        int ix = this->listA.find(a);
        B result = this->listB.getAt(ix);
        return result;
    }

    void clear(A a)
    {
        int ix = this->listA.find(a);
        this->removeAt(ix);
    }

    int getSize()
    {
        return this->listA.getSize();
    }
};

#endif
