add(obj, delay) {
        if (obj.queueProperties.inQueue) {
            obj.queueProperties.time = this.time + (delay || obj.propagationDelay);
            let i = obj.queueProperties.index;
            while (i > 0 && obj.queueProperties.time > this.queue[i - 1].queueProperties.time) {
                this.swap(i, i - 1);
                i--;
            }
            i = obj.queueProperties.index;
            while (i < this.frontIndex - 1 && obj.queueProperties.time < this.queue[i + 1].queueProperties.time) {
                this.swap(i, i + 1);
                i++;
            }
            return;
        }

        if (this.frontIndex == this.size) throw 'EventQueue size exceeded';
        this.queue[this.frontIndex] = obj;
        // obj.queueProperties.time=obj.propagationDelay;
        obj.queueProperties.time = this.time + (delay || obj.propagationDelay);
        obj.queueProperties.index = this.frontIndex;
        this.frontIndex++;
        obj.queueProperties.inQueue = true;
        let i = obj.queueProperties.index;
        while (i > 0 && obj.queueProperties.time > this.queue[i - 1].queueProperties.time) {
            this.swap(i, i - 1);
            i--;
        }
    }
@param {CircuitElement} obj - the elemnt to be added
@param {number} delay - the delay in adding an object to queue