import java.util.ArrayList;

public class Walksort {

	protected Gridlist[][] sort;
	
	public Walksort(int x, int y){
		sort = new Gridlist[x][y];
		for(int i=0;i<x;i++){
			for(int j=0;j<y;j++){
				sort[i][j]=new Gridlist();
			}
		}
	}
	
	public Walksort(int x){
		sort = new Gridlist[x][x];
		for(int i=0;i<x;i++){
			for(int j=0;j<x;j++){
				sort[i][j]=new Gridlist();
			}
		}
	}
	
	public Walksort(Gridlist[][] so){
		sort = so;
	}
		
	public Gridlist[][] getSort(){
		return sort;
	}
	
	public Gridlist getSortEntry(int x, int y){
		return sort[x][y];
	}
	
	public void add(int x, int y, Position e){
		sort[x][y].add(e);
	}
	
	public void add(Position a, Position e){
		sort[a.getx()][a.gety()].add(e);
	}
	
	public void initialize(Walk tet){
		ArrayList<Position> map = tet.getMap();
		for(int i=0;i<map.size()-2;i++){
			this.add(map.get(i),map.get(i+1));
		}
	}
	
	
}
