open Position

type t = (int, (position * int)) Hashtbl.t

let no_info = -10000

let make size = Hashtbl.create size 

let get tbl id = 
  try
    Hashtbl.find tbl id
  with 
  | Not_found -> ({x=0; y=0}, no_info)

let set tbl id pos date = 
  Hashtbl.replace tbl id (pos,date)

let update tbl id pos date = 
  try
    let _, date_tbl = Hashtbl.find tbl id in
    if date > date_tbl then
      Hashtbl.replace tbl id (pos,date)
  with
  | Not_found ->  Hashtbl.add tbl id (pos,date)