The PostgreSQL source distribution includes several examples of index operator classes for SP-GiST, as described in Table 66.1. Look into src/backend/access/spgist/ and src/backend/utils/adt/ to see the code.
src/backend/access/spgist/
src/backend/utils/adt/