Native Nit array

Access are unchecked and it has a fixed size Not for public use: may become private.

Introduced properties

intern fun [](index: Int): E

core :: NativeArray :: []

Get item at index.
intern fun []=(index: Int, item: E)

core :: NativeArray :: []=

Set item at index.
intern fun copy_to(dest: NativeArray[E], length: Int)

core :: NativeArray :: copy_to

Copy length items to dest.
intern fun length: Int

core :: NativeArray :: length

The length of the array
intern fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int)

core :: NativeArray :: memmove

Copy length items to dest starting from dest.
abstract fun native_to_s: String

core :: NativeArray :: native_to_s

Join all the elements using to_s
intern init new(length: Int): NativeArray[E]

core :: NativeArray :: new

Creates a new NativeArray of capacity length
fun to_a: Array[E]

core :: NativeArray :: to_a

Use self to initialize a standard Nit Array.

Redefined properties

redef type SELF: NativeArray[E]

core $ NativeArray :: SELF

Type of this instance, automatically specialized in every class
redef fun native_to_s: String

core :: flat $ NativeArray :: native_to_s

Join all the elements using to_s

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
intern fun [](index: Int): E

core :: NativeArray :: []

Get item at index.
intern fun []=(index: Int, item: E)

core :: NativeArray :: []=

Set item at index.
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
intern fun copy_to(dest: NativeArray[E], length: Int)

core :: NativeArray :: copy_to

Copy length items to dest.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun length: Int

core :: NativeArray :: length

The length of the array
intern fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int)

core :: NativeArray :: memmove

Copy length items to dest starting from dest.
abstract fun native_to_s: String

core :: NativeArray :: native_to_s

Join all the elements using to_s
intern init new(length: Int): NativeArray[E]

core :: NativeArray :: new

Creates a new NativeArray of capacity length
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_a: Array[E]

core :: NativeArray :: to_a

Use self to initialize a standard Nit Array.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram core::NativeArray NativeArray core::Object Object core::NativeArray->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

core $ NativeArray
# Native Nit array
# Access are unchecked and it has a fixed size
# Not for public use: may become private.
universal NativeArray[E]
	# Creates a new NativeArray of capacity `length`
	new(length: Int) is intern
	# The length of the array
	fun length: Int is intern
	# Use `self` to initialize a standard Nit Array.
	fun to_a: Array[E] do return new Array[E].with_native(self, length)

	# Get item at `index`.
	fun [](index: Int): E is intern

	# Set `item` at `index`.
	fun []=(index: Int, item: E) is intern

	# Copy `length` items to `dest`.
	fun copy_to(dest: NativeArray[E], length: Int) is intern

	# Copy `length` items to `dest` starting from `dest`.
	fun memmove(start: Int, length: Int, dest: NativeArray[E], dest_start: Int) is intern do
		if start < dest_start then
			var i = length
			while i > 0 do
				i -= 1
				dest[dest_start+i] = self[start+i]
			end
		else
			var i = 0
			while i < length do
				dest[dest_start+i] = self[start+i]
				i += 1
			end
		end
	end

	#fun =(o: NativeArray[E]): Bool is intern
	#fun !=(o: NativeArray[E]): Bool is intern
end
lib/core/collection/array.nit:977,1--1016,3

core :: abstract_text $ NativeArray
redef class NativeArray[E]
	# Join all the elements using `to_s`
	#
	# REQUIRE: `self isa NativeArray[String]`
	# REQUIRE: all elements are initialized
	fun native_to_s: String is abstract
end
lib/core/text/abstract_text.nit:2562,1--2568,3

core :: flat $ NativeArray
redef class NativeArray[E]
	redef fun native_to_s do
		assert self isa NativeArray[String]
		var l = length
		var na = self
		var i = 0
		var sl = 0
		var mypos = 0
		while i < l do
			sl += na[i].byte_length
			i += 1
			mypos += 1
		end
		var ns = new CString(sl + 1)
		ns[sl] = 0
		i = 0
		var off = 0
		while i < mypos do
			var tmp = na[i]
			if tmp isa FlatString then
				var tpl = tmp._byte_length
				tmp._items.copy_to(ns, tpl, tmp._first_byte, off)
				off += tpl
			else
				for j in tmp.substrings do
					var s = j.as(FlatString)
					var slen = s._byte_length
					s._items.copy_to(ns, slen, s._first_byte, off)
					off += slen
				end
			end
			i += 1
		end
		return new FlatString.with_infos(ns, sl, 0)
	end
end
lib/core/text/flat.nit:1533,1--1568,3