Make Sets use arrays as buffers, share more code between Map and Set

Summary: This diff refactors Map and Set to share a lot of their implementation,
and in doing so makes Sets use arrays as buffers (like Maps).

Reviewed By: @elgenie

Differential Revision: D1421364