Interface for generic lexicographic encoding and decoding