Slow Performance on TLinkedHashSet::remove

Issue #76 new
Shiang-Yun Yang created an issue
public static void main(String[] args) {
    TLinkedHashSet<Object> t = new TLinkedHashSet<>();

    long start = System.currentTimeMillis();
    int n = 10000000;
    for (int i = 0; i < n; i++)
        t.add(i);
    for (int i = 0; i < n; i++)
        t.remove(i);
    long end = System.currentTimeMillis();
    System.out.printf("%f\n", (end - start) / 1000.0);
}

I think TLinkedHashSet is still not an alternative collection of LinkedHashSet. When operate the remove action, it performs linear time O(n) on internal array allocation.

Comments (0)

  1. Log in to comment