1. A method for setting elements in a result vector based on an input vector, comprising: receiving the input vector, wherein the input vector includes a set of N elements; determining a location of a key element in the input vector; and generating a result vector, wherein generating the result vector involves setting one or more elements of the result vector based on the location of the key element in the input vector.