class NamedObjectTable extends Info;

var private array<name> Names;
var private array<Object> Objects;

// looks for the table or creates a new one, if such doesn't exist
static function NamedObjectTable InitTable(LevelInfo Level, optional name TableTag) 
{
	local Actor Other;
	
	foreach Level.AllActors(default.class, Other, TableTag)
		return NamedObjectTable(Other);

	return Level.spawn(default.class, Level, TableTag);
}


function ClearTable()
{
	Names.length = 0;
	Objects.length = 0;
}

function int TableLength()
{
	return Names.Length;
}

// returns Names.length if not foud
function protected int GetIndex(name ObjectName)
{
	local int i;
	
	for ( i=0; i<Names.length; ++i )
		if ( Names[i] == ObjectName )
			break;
	
	return i;
}



function SetObject(name ObjectName, Object Object)
{
	local int i;
	
	i = GetIndex(ObjectName);
	Names[i] = ObjectName;
	Objects[i] = Object;
}

function Object GetObject(name ObjectName)
{
	local int i;
	
	i = GetIndex(ObjectName);
	
	if ( i < Objects.length )
		return Objects[i];

	return none;
}

defaultproperties
{
}
