Package org.gnome.glib
Class SList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<@Nullable E>
org.gnome.glib.SList<E>
- Type Parameters:
E- The element type must be aMemorySegment, aString, a primitive value, or implement theProxyinterface.
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>,Proxy
Java wrapper for GLib.SList
that implements
List.
Because SList is a singly-linked list, attempts to navigate the list
backwards will throw an UnsupportedOperationException.
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionSList(MemorySegment address, Function<MemorySegment, E> make, @Nullable Consumer<E> free, TransferOwnership ownership) Create a newGLib.SListwrapper.SList(MemorySegment address, Function<MemorySegment, E> make, TransferOwnership ownership) Create a newGLib.SListwrapper.SList(Function<MemorySegment, E> make, Consumer<E> free, TransferOwnership ownership) Create a wrapper for a new, emptyGLib.SList. -
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.SList(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
-
SList
public SList(MemorySegment address, Function<MemorySegment, E> make, @Nullable Consumer<E> free, TransferOwnership ownership) Create a newGLib.SListwrapper.- Parameters:
address- the memory address of the head element of the SListmake- 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
-
SList
Create a wrapper for a new, emptyGLib.SList.- 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
-
SList
Create a newGLib.SListwrapper.- Parameters:
address- the memory address of the head element of the SListmake- 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.SList(in proper sequence).Because SList is a singly-linked list, the following iterator methods will throw an
UnsupportedOperationException:- 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.SList head, or
MemorySegment.NULLif the head isnull.
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout of one list node
-