// Restructures an RVList if it has degraded severely. Time: O(Count) void AutoOptimize <T>(ref RVList <T> v) { // Check if the chain length substantially exceeds Sqrt(v.Count) if ((v.BlockChainLength - 10) * (v.BlockChainLength - 10) > v.Count) { RWList <T> w = v.ToRWList(); // This is basically a no-op w[0] = w[0]; // Restructure & make mutable v = w.ToRVList(); // Mark immutable again } }