The PostgreSQL™ source distribution includes
several examples of index operator classes for
SP-GiST. The core system currently provides radix
trees over text columns and two types of trees over points: quad-tree and
k-d tree. Look into src/backend/access/spgist/
to see the
code.