Finds the position of a shard with the given id within the context (via binary search).
484942
@VisibleForTesting
    public int findPositionOf(ByteBuffer context, CounterId id)
    {
        int headerLength = headerLength(context);
        int offset = context.position() + headerLength;

        int left = 0;
        int right = (context.remaining() - headerLength) / STEP_LENGTH - 1;

        while (right >= left)
        {
            int middle = (left + right) / 2;
            int cmp = compareId(context, offset + middle * STEP_LENGTH, id.bytes(), id.bytes().position());

            if (cmp == -1)
                left = middle + 1;
            else if (cmp == 0)
                return offset + middle * STEP_LENGTH;
            else
                right = middle - 1;
        }

        return -1; // position not found
    }
600989
def object_by_id(id)
      idx = id & @mask
      # The index is just a hash. We still need to check if the object IDs are
      # actually the same before we can return the object.
      if (obj = @writes[idx]) && obj._id == id
        # The object was in the write cache.
        return obj
      elsif (obj = @reads[idx]) && obj._id == id
        # The object was in the read cache.
        return obj
      end

      nil
    end
897313
def _get_shard(self, shard):
        """"""
        @wraps(API_WRAPPER._get_shard)
        def get_shard(*arg, **kwargs):
            """Gets the shard '{}'""".format(shard)
            return self.get_shards(Shard(shard, *arg, **kwargs))
        return get_shard
595127
private int find(int key, int hash) {
        int index = index(hash);
        final int maxTry = capacity;
        for (int i = 0; i < maxTry; i++) {
            Object slot = values[index];
            if (slot == null) return -1;
            if (slot != GUARD) return keys[index] == key ? index : -1;
            index = nextIndex(index);
        }
        return -1;
    }
1215939
public Record findRecordById(String id) {
    if (directory == null)
      init();

    Property idprop = config.getIdentityProperties().iterator().next();
    for (Record r : lookup(idprop, id))
      if (r.getValue(idprop.getName()).equals(id))
        return r;

    return null; // not found
  }
68400
def find(self, key):
        ""
        index = self.follow_bytes(key, self.ROOT)
        if index is None:
            return -1
        if not self.has_value(index):
            return -1
        return self.value(index)
838019
def find(self, id, **kwargs):
        
        return self.find_by(values={self.primary_key: id}, **kwargs)
1287700
def _one_prob_per_shard(args: Dict[str, Any]) -> float:
    
    index = args['index']

    state = _state_shard(args) * _one_projector(args, index)
    norm = np.linalg.norm(state)
    return norm * norm
558244
@Override
  public Iterator<E> shardIterator(int shardId, int numShards) {
    if (shardId >= entries.length) {
      return null;
    }
    if (shardId >= numShards) {
      throw new IllegalArgumentException(
          "Shard id must be less than total shards, shardId: " + shardId
              + ", numShards: " + numShards);
    }
    return new SetIterator(shardId, numShards);
  }
281424
private long getIndexVersion(List<ShardIndexVersion> shards) {
    long version = 1;

    // order shards per their id before computing the hash
    Collections.sort(shards, new Comparator<ShardIndexVersion>() {
      @Override
      public int compare(ShardIndexVersion o1, ShardIndexVersion o2) {
        return o1.getShardRouting().id() - o2.getShardRouting().id();
      }
    });

    // compute hash
    for (ShardIndexVersion shard : shards) {
      version = 31 * version + shard.getVersion();
    }

    return version;
  }
359313
def find(self, space_id, query=None, **kwargs):
        

        try:
            self.space_id = space_id
            return super(SpacesProxy, self).find(space_id, query=query)
        finally:
            self.space_id = None
810124
def find_self(_id,resource,options={})
			conditions = {:_id => _id}
			conditions[:resource_id] = resource.id.to_s if !resource.is_admin?
			#puts "conditions are:"
			#puts conditions.to_s
			all = self.where(conditions)
			#puts "the resultant size:"
			#puts all.size.to_s
			return all.first if all.size > 0 
			return nil
		end
1105169
def find_room_by_id(id)
      id = id.to_i
      rooms.detect { |room| room.id == id }
    end
582730
function findPosition(array, id) {
    var position = -1;

    for(var i = 0, len = array.length; i < len; i += 1) {
        if(array[i].$id === id) position = i;
    }

    return position;
}
480200
def _find_id(self, id_):
        """"""
        for i, row in enumerate(self._data):
            if row["id"] == id_:
                t = self.tableWidget
                # idx = t.itemFromIndex()
                t.setCurrentCell(i, 0)
                break
689127
private int searchInternal(Composite name, int startIdx)
    {
        if (isEmpty())
            return -1;

        int pos = Arrays.binarySearch(starts, startIdx, size, name, comparator);
        if (pos >= 0)
        {
            // We're exactly on an interval start. The one subtility is that we need to check if
            // the previous is not equal to us and doesn't have a higher marked at
            if (pos > 0 && comparator.compare(name, ends[pos-1]) == 0 && markedAts[pos-1] > markedAts[pos])
                return pos-1;
            else
                return pos;
        }
        else
        {
            // We potentially intersect the range before our "insertion point"
            int idx = -pos-2;
            if (idx < 0)
                return -1;

            return comparator.compare(name, ends[idx]) <= 0 ? idx : -idx-2;
        }
    }
560945
def _find_by_sha1(self, sha1):
        
        for image_part in self:
            # ---skip unknown/unsupported image types, like SVG---
            if not hasattr(image_part, 'sha1'):
                continue
            if image_part.sha1 == sha1:
                return image_part
        return None