Package org.gnome.glib
Class List<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<@Nullable E>
org.gnome.glib.List<E>
- Type Parameters:
E- The element type must be aMemorySegment, aString, a primitive value, or implement theProxyinterface. It is assumed that integers are stored in the pointer withGINT_TO_POINTER()andGPOINTER_TO_INT().
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>,Proxy
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionList(@Nullable MemorySegment address, Function<@Nullable MemorySegment, E> make, @Nullable Consumer<@Nullable E> free, TransferOwnership ownership) Create a newGLib.Listwrapper.List(@Nullable MemorySegment address, Function<@Nullable MemorySegment, E> make, TransferOwnership ownership) Create a newGLib.Listwrapper.List(Function<@Nullable MemorySegment, E> make, @Nullable Consumer<E> free, TransferOwnership ownership) Create a wrapper for a new, emptyGLib.List. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryLayoutThe memory layout of the native struct.handle()Returns the memory address of the head of the list.booleanisEmpty()Checks if the list has no elements (the head of the list isnull).listIterator(int index) Returns a list iterator over the elements in thisGLib.List(in proper sequence).voidsetOwnership(TransferOwnership ownership) Change ownership status of this listintsize()Retrieve the size of the list.Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, setMethods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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(@Nullable MemorySegment address, Function<@Nullable MemorySegment, E> make, @Nullable Consumer<@Nullable E> free, TransferOwnership ownership) Create a newGLib.Listwrapper.- Parameters:
address- the memory address of the head element of the Listmake- a function to construct element instancesfree- a function to free element instances. Ifownershipis "none" or "container", this can safely be set tonull.ownership- whether to free memory automatically
-
List
public List(Function<@Nullable MemorySegment, E> make, @Nullable Consumer<E> free, TransferOwnership ownership) Create a wrapper for a new, emptyGLib.List.- Parameters:
make- a function to construct element instancesfree- a function to free element instances. Ifownershipis "none" or "container", this can safely be set tonull.ownership- whether to free memory automatically
-
List
public List(@Nullable MemorySegment address, Function<@Nullable MemorySegment, E> make, TransferOwnership ownership) Create a newGLib.Listwrapper.- Parameters:
address- the memory address of the head element of the Listmake- a function to construct element instancesownership- whether to free memory automatically
-
-
Method Details
-
setOwnership
Change ownership status of this list- Parameters:
ownership- the new ownership status
-
listIterator
Returns a list iterator over the elements in thisGLib.List(in proper sequence).- Specified by:
listIteratorin interfaceList<E>- Specified by:
listIteratorin classAbstractSequentialList<@Nullable E>- Parameters:
index- index of first element to be returned from the list iterator (by a call to thenextmethod)- 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:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein 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:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceList<E>- Overrides:
isEmptyin 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:
handlein interfaceProxy- Returns:
- the memory address of the current GLib.List head, or
MemorySegment.NULLif the head isnull.
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout of one list node
-