Return the first component from stream.
979559
def readOne(stream, validate=False, transform=True, ignoreUnreadable=False,
            allowQP=False):
    
    return next(readComponents(stream, validate, transform, ignoreUnreadable,
                               allowQP))
218625
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) {
        int first = -1;
        boolean atomBoundary = true;
        for (int i = beginIndex; i >= rewindIndex; i--) {
            char c = input.charAt(i);
            if (localAtomAllowed(c)) {
                first = i;
                atomBoundary = false;
            } else if (c == '.') {
                if (atomBoundary) {
                    break;
                }
                atomBoundary = true;
            } else {
                break;
            }
        }
        return first;
    }
591300
@Override
	public <T> Optional<T> findFirst(final Class<T> type) {
		try (Stream<T> stream = stream(new EntityResultSetConverter<>(type, new PropertyMapperManager()))) {
			return stream.findFirst();
		}
	}
39253
public T first() {
        Iterator<T> iterator = iterator();
        return (iterator.hasNext() ? iterator.next() : null);
    }
36073
def first(pipe, items=1):
    ''' 
    '''
    pipe = iter(pipe)
    return next(pipe) if items == 1 else islice(pipe, 0, items)
919686
def first(self):
        """"""
        with self.lock:
            try:
                return self.data[0][0]
            except IndexError as ex:
                ex.args = ('DEPQ is empty',)
                raise
1279205
public String getFirst(String name, String defaultValue)
    {
        String value = getFirst(name);
        if (value == null) {
            value = defaultValue;
        }
        return value;
    }
1083631
def FromStream(cls, stream):
        

        if stream.system:
            specifier = DataStreamSelector.MatchSystemOnly
        else:
            specifier = DataStreamSelector.MatchUserOnly

        return DataStreamSelector(stream.stream_type, stream.stream_id, specifier)
75402
def stream(self):
        """"""
        stream = self._p4dict.get('stream')
        if stream:
            return Stream(stream, self._connection)
567916
def _run_first(self, source_file):
        """"""

        self.reset()
        self.current_encoding = self.default_encoding
        encoding = None
        try:
            encoding = self._detect_encoding(source_file)
            content = self.filter(source_file, encoding)
        except UnicodeDecodeError:
            if not encoding or encoding != self.default_encoding:
                content = self.filter(source_file, self.default_encoding)
            else:
                raise
        return content
143682
def first(self, callback=None, default=None):
        
        if callback is not None:
            for val in self.items:
                if callback(val):
                    return val

            return value(default)

        if len(self.items) > 0:
            return self.items[0]
        else:
            return default
1218657
def _get_component(self, string, initial_pos):
    '''  '''
    add_code = string[initial_pos:initial_pos + self.ADDR_CODE_LENGTH]
    
    if add_code == 'REM':
      raise ish_reportException("This is a remarks record")
    if add_code == 'EQD':
      raise ish_reportException("This is EQD record")

    initial_pos += self.ADDR_CODE_LENGTH 
    try:
      useable_map = self.MAP[add_code]
    except:
      raise BaseException("Cannot find code %s in string %s (%d)." % (add_code, string, initial_pos))

    # if there is no defined length, then read next three chars to get it
    # this only applies to REM types, which have 3 chars for the type, then variable
    if useable_map[1] is False:
      chars_to_read = string[initial_pos + self.ADDR_CODE_LENGTH:initial_pos + \
                      (self.ADDR_CODE_LENGTH * 2)]
      chars_to_read = int(chars_to_read)
      initial_pos += (self.ADDR_CODE_LENGTH * 2)
    else:
      chars_to_read = useable_map[1]

    new_position = initial_pos + chars_to_read
    string_value = string[initial_pos:new_position]

    try:
      object_value = useable_map[2]()
      object_value.loads(string_value)
    except IndexError as err:
      object_value = string_value

    return (new_position, [add_code, object_value])
367970
public int first() {
    assertNonEmpty();
    short firstKey = keys[0];
    Container container = values[0];
    return firstKey << 16 | container.first();
  }
905651
def filtfirst(entities, **kw):
  """"""
  ret = sorted(filtany(entities, **kw), key=lambda x:x.id())
  if not ret:
    raise ValueError('No result')
  return ret[0]
583594
public SimpleEntry getFirst()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "getFirst");

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(this, tc, "getFirst", new Object[] {first, printList()});
    
    return first;          
  }
1267773
def get_component(self, component_type):
        '''
        
        '''
        matching_components = list(filter(lambda component:
                                          isinstance(component,
                                                     component_type),
                                          self._components))
        if matching_components:
            return matching_components[0]
        else:
            return None
655671
def FindFirst(params, ctxt, scope, stream, coord, interp):
    
    global FIND_MATCHES_ITER
    FIND_MATCHES_ITER = _find_helper(params, ctxt, scope, stream, coord, interp)

    try:
        first = six.next(FIND_MATCHES_ITER)
        return first.start() + FIND_MATCHES_START_OFFSET
    except StopIteration as e:
        return -1