Java: A “prime” number or a “power of two” as HashMap size?

Using a power of two effectively masks out top bits of the hash code. Thus a poor-quality hash function might perform particularly badly in this scenario. Java’s HashMap mitigates this by mistrusting the object’s hashCode() implementation and applying a second level of hashing to its result: Applies a supplemental hash function to a given hashCode, … Read more

Using as a concrete type conforming to protocol AnyObject is not supported

I ran into the same problem when I tried to implement weak containers. As @plivesey points out in a comment above, this seems to be a bug in Swift 2.2 / Xcode 7.3, but it is expected to work. However, the problem does not occur for some Foundation protocols. For example, this compiles: let container … Read more

Why are tuples constructed from differently initialized sets equal?

At first glance, it appears that x should always equal y, because two sets constructed from the same elements are always equal: >>> x = set([1, “a”, “b”, “c”, “z”, “f”]) >>> y = set([“a”, “b”, “c”, “z”, “f”, 1]) >>> x {1, ‘z’, ‘a’, ‘b’, ‘c’, ‘f’} >>> y {1, ‘z’, ‘a’, ‘b’, ‘c’, … Read more

Hashtables and key order

There is no built-in solution in PowerShell V1 / V2. You will want to use the .NET System.Collections.Specialized.OrderedDictionary: $order = New-Object System.Collections.Specialized.OrderedDictionary $order.Add(“Switzerland”, “Bern”) $order.Add(“Spain”, “Madrid”) $order.Add(“Italy”, “Rome”) $order.Add(“Germany”, “Berlin”) PS> $order Name Value —- —– Switzerland Bern Spain Madrid Italy Rome Germany Berlin In PowerShell V3 you can cast to [ordered]: PS> [ordered]@{“Switzerland”=”Bern”; “Spain”=”Madrid”; … Read more

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