Hi, Im trying to create a tree-structure and am trying to delete some elements from the tree. I dont quite understand why the MyHashTable.Remove(#key) is causing this exepction:
InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. System.Collections.Hashtable + Enumerator.FailFast()
the key does not have to be a string if i read it correctly? Im using ints as keys.
protected var idListe : Hashtable = new Hashtable();
public function remove(nodeId:int){
var startId = idListe[nodeId].getIdLeft();
var targetId = idListe[nodeId].getIdRight();
var endId = idListe[0].getIdRight();
for (var item : DictionaryEntry in idListe){
var id:int = item.Value.getId();
var idLeft:int = item.Value.getIdLeft();
var idRight:int = item.Value.getIdRight();
Debug.Log("Checking (" + nodeId + "):"+id+" => " +idLeft + " >= " + startId + " && " +idRight + " <= " + targetId);
if (idLeft >= startId && idRight <= targetId){
Debug.Log("Deleting:"+id);
idListe.Remove(id);
}
}
updateIdListe(startId ,endId,(targetId-startId));
}