
import { ObjectType } from 'typescript';
import Track from './Track'


class TrackListCLass
{
    constructor()
        {
            this.trackMap = new Map<string, Track>();
        }
    
    
    trackMap: Map<string, Track>  ;

   
    getTrack(id :string)
    {
        return this.trackMap.get(id);
    }

    isInList(id :string)
    {
        return this.trackMap.has(id);
    }

    addTrack(track :Track)
    {
        this.trackMap.set(track.Id,track);
    }

    updateTrack(input: { id: string; Name: string; Course: number; Speed: number; External: boolean; Height: number; Position: number[]; Type: string; Side: string; })
    {
        
      var Track =   this.trackMap.get(input.id);
      if(Track === undefined)
      {
        return;
      }

      if(Track.isOnEdit === false)
      {
        Track.Name = input.Name;
        Track.Course = input.Course;
        Track.Speed = input.Speed;
        Track.External = input.External;
        Track.Height = input.Height;
        Track.Position = input.Position;
        Track.Type = input.Type;
        Track.Side = input.Side;
       
      }
    }

    getKeys()
    {
        return this.trackMap.keys;
    }
    getSize()
    {
        return this.trackMap.size;
    }

    getTracks() 
    {   
        var Tracks = new Array<Track>();
        this.trackMap.forEach((val,index) => 
            Tracks.push(val)
        )
        

        return Tracks;
    }


    getTrackMap()
    {
        return this.trackMap;
    }

   
}


export default  TrackListCLass