How do I sort a collection?

Late to the game… here’s an implementation of the MergeSort algorithm in VBA for both Arrays and Collections. I tested the performance of this implementation against the BubbleSort implementation in the accepted answer using randomly generated strings. The chart below summarizes the results, i.e. that you should not use BubbleSort to sort a VBA collection. … Read more

Generic tree implementation in Java

Here it comes: abstract class TreeNode implements Iterable<TreeNode> { private Set<TreeNode> children; public TreeNode() { children = new HashSet<TreeNode>(); } public boolean addChild(TreeNode n) { return children.add(n); } public boolean removeChild(TreeNode n) { return children.remove(n); } public Iterator<TreeNode> iterator() { return children.iterator(); } } I am well trusted, but haven’t tested the implementation.

Converting mutable collection to immutable

If you want to convert ListBuffer into a List, use .toList. I mention this because that particular conversion is performed in constant time. Note, though, that any further use of the ListBuffer will result in its contents being copied first. Otherwise, you can do collection.immutable.Seq(xs: _*), assuming xs is mutable, as you are unlikely to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)