Return the first item of the collection

assert [1,2,3].first                == 1

Property definitions

core $ Collection :: first
	# Return the first item of the collection
	#
	#     assert [1,2,3].first                == 1
	fun first: E
	do
		assert length > 0
		return iterator.item
	end
lib/core/collection/abstract_collection.nit:129,2--136,4

core $ SequenceRead :: first
	# Get the first item.
	# Is equivalent with `self[0]`.
	#
	#     var a = [1,2,3]
	#     assert a.first   == 1
	#
	# REQUIRE `not is_empty`
	redef fun first
	do
		assert not_empty: not is_empty
		return self[0]
	end
lib/core/collection/abstract_collection.nit:839,2--850,4

core $ Range :: first
	redef var first
lib/core/collection/range.nit:22,2--16

pthreads $ ConcurrentCollection :: first
	redef fun first
	do
		mutex.lock
		var r = real_collection.first
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:92,2--98,4

core $ Ref :: first
	redef fun first do return item
lib/core/collection/abstract_collection.nit:358,2--31

core $ ArrayMapKeys :: first
	redef fun first do return self.map._items.first.first
lib/core/collection/array.nit:807,2--54

core $ ArrayMapValues :: first
	redef fun first do return self.map._items.first.second
lib/core/collection/array.nit:826,2--55

core $ HashMapKeys :: first
	redef fun first do return self.map._first_item._key
lib/core/collection/hash_collection.nit:291,2--52

core $ HashMapValues :: first
	redef fun first do return self.map._first_item._value
lib/core/collection/hash_collection.nit:321,2--54

ordered_tree $ OrderedTree :: first
	#     var tree = new OrderedTree[Int]
	#     tree.add(null, 1)
	#     tree.add(1, 11)
	#     assert tree.first == 1
	redef fun first do return roots.first
lib/ordered_tree/ordered_tree.nit:229,2--233,38

core $ Queue :: first
	# `first` is made an alias of `peek` to avoid bad surprises
	redef fun first do return peek
lib/core/queue.nit:74,2--75,31

core $ ArraySet :: first
	redef fun first
	do
		assert _array.length > 0
		return _array.first
	end
lib/core/collection/array.nit:608,2--612,4

core $ List :: first
	# O(1)
	redef fun first do return _head.as(not null).item
lib/core/collection/list.nit:28,2--29,50

dummy_array $ DummyArray :: first
	redef fun first: Int
	do
		assert _length > 0
		return _values[0]
	end
lib/dummy_array/dummy_array.nit:56,2--60,4

core $ HashSet :: first
	redef fun first
	do
		assert _the_length > 0
		return _first_item._key
	end
lib/core/collection/hash_collection.nit:436,2--440,4