虚拟内存算法

class VirtualMemory {
    r = 0;
    s = 0;
    score = 0;
    constructor (score) {
        this.r = Math.floor(Math.random() * 1e7 + 1157);
        this.set(score);
    }
    check () {
        if (this.s !== ((this.score + 117) ^ (this.r - 117))) {
            this.score = (this.s ^ (this.r - 117)) - 117;
        }
    }
    get () {
        return this.score ^ this.r;
    }
    add (score) {
        this.check();
        this.set(this.get() + score);
    }
    set (score) {
        this.score = score ^ this.r;
        this.s = (this.score + 117) ^ (this.r - 117);
    }
    toJSON () {
        return this.get();
    }
    toString () {
        return this.get();
    }
}

 

posted @ 2025-03-27 11:03  浪浪辛  阅读(14)  评论(0)    收藏  举报