Package org.gnome.glib
Class List<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
org.gnome.glib.List<E>
- Type Parameters:
E
- The element type must be aMemorySegment
, aString
, a primitive value, or implement theProxy
interface.
- All Implemented Interfaces:
Proxy
,Iterable<E>
,Collection<E>
,List<E>
,SequencedCollection<E>
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorDescriptionList
(MemorySegment address, Function<MemorySegment, E> make, boolean fullOwnership) Create a newGLib.List
wrapper.List
(MemorySegment address, Function<MemorySegment, E> make, Consumer<E> free, boolean fullOwnership) Create a newGLib.List
wrapper.Create a wrapper for a new, emptyGLib.List
. -
Method Summary
Modifier and TypeMethodDescriptionhandle()
Returns the memory address of the head of the list.boolean
isEmpty()
Checks if the list has no elements (the head of the list isnull
).@NotNull ListIterator
<E> listIterator
(int index) Returns a list iterator over the elements in thisGLib.List
(in proper sequence).int
size()
Retrieve the size of the list.Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, set
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Constructor Details
-
List
public List(MemorySegment address, Function<MemorySegment, E> make, Consumer<E> free, boolean fullOwnership) Create a newGLib.List
wrapper.- Parameters:
address
- the memory address of the head element of the Listmake
- a function to construct element instancesfree
- a function to free element instances. IffullOwnership
isfalse
, this can safely be set tonull
.fullOwnership
- whether to free element instances automatically
-
List
Create a wrapper for a new, emptyGLib.List
.- Parameters:
make
- a function to construct element instancesfree
- a function to free element instances. IffullOwnership
isfalse
, this can safely be set tonull
.fullOwnership
- whether to free element instances automatically
-
List
Create a newGLib.List
wrapper.- Parameters:
address
- the memory address of the head element of the Listmake
- a function to construct element instancesfullOwnership
- whether to free element instances automatically withGLib.free(java.lang.foreign.MemorySegment)
-
-
Method Details
-
listIterator
Returns a list iterator over the elements in thisGLib.List
(in proper sequence).- Specified by:
listIterator
in interfaceList<E>
- Specified by:
listIterator
in classAbstractSequentialList<E>
- Parameters:
index
- index of first element to be returned from the list iterator (by a call to thenext
method)- Returns:
- a list iterator over the elements in this list (in proper sequence).
-
size
public int size()Retrieve the size of the list. This is an expensive operation for long lists, because the entire length must be traversed.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in classAbstractCollection<E>
- Returns:
- the length of the list
-
isEmpty
public boolean isEmpty()Checks if the list has no elements (the head of the list isnull
).- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceList<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
- Returns:
- whether the list is empty
-
handle
Returns the memory address of the head of the list. This address can change if the list is modified.- Specified by:
handle
in interfaceProxy
- Returns:
- the memory address of the current GLib.List head, or
MemorySegment.NULL
if the head isnull
.
-