Avoid new[0].

-- RMonica
Add weighted variant.

-- RMonica