SceneJS_Map = function() {
    this.items = [];
    this.lastUniqueId = 0;

    this.addItem = function() {
        var item;
        if (arguments.length == 2) {
            var id = arguments[0];
            item = arguments[1];
            if (this.items[id]) { // Won't happen if given ID is string
                throw SceneJS_errorModule.fatalError(SceneJS.errors.ID_CLASH, "ID clash: '" + id + "'");
            }
            this.items[id] = item;
            return id;
        } else {
            while (true) {
                item = arguments[0];
                var findId = this.lastUniqueId++ ;
                if (!this.items[findId]) {
                    this.items[findId] = item;
                    return findId;
                }
            }
        }
    };

    this.removeItem = function(id) {
        this.items[id] = null;
    };
}
Generic map of IDs to items - can generate own IDs or accept given IDs.
Given IDs should be strings in order to not clash with internally generated IDs, which are numbers.