The code is similar, but it expect large **sorted** input. array_offset works on unsorted (alphabetical unsorted) data sets - like days of week ..
The functions are serving rather different purposes, so I'm not sure it's worth mentioning. If we do want to mention it, then something like the following should be added to *both* functions:
ok, I removed this note.
I added comment about wrapping and I simplified a code there - this method is used more time in pg for same purposes.
Merged Jim's changes in doc
Pavel
* This code is similar to width_bucket()
and
* This code is similar to array_offset()
Incidentally, isn't it bad that we're doing all these static assignments inside the loop in width_bucket? Or can we count on the compiler to recognize this?