Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GListStore
is a simple implementation of ListModel
that stores
all items in memory.
It provides insertions, deletions, and lookups in logarithmic time with a fast path for the common case of iterating the list linearly.
Synopsis
- newtype ListStore = ListStore (ManagedPtr ListStore)
- class (GObject o, IsDescendantOf ListStore o) => IsListStore o
- toListStore :: (MonadIO m, IsListStore o) => o -> m ListStore
- listStoreAppend :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> b -> m ()
- listStoreFind :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> b -> m (Bool, Word32)
- listStoreFindWithEqualFunc :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> Maybe b -> EqualFunc -> m (Bool, Word32)
- listStoreFindWithEqualFuncFull :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> Maybe b -> EqualFuncFull -> m (Bool, Word32)
- listStoreInsert :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> Word32 -> b -> m ()
- listStoreInsertSorted :: (HasCallStack, MonadIO m, IsListStore a, IsObject b) => a -> b -> CompareDataFunc -> m Word32
- listStoreNew :: (HasCallStack, MonadIO m) => GType -> m ListStore
- listStoreRemove :: (HasCallStack, MonadIO m, IsListStore a) => a -> Word32 -> m ()
- listStoreRemoveAll :: (HasCallStack, MonadIO m, IsListStore a) => a -> m ()
- listStoreSort :: (HasCallStack, MonadIO m, IsListStore a) => a -> CompareDataFunc -> m ()
- listStoreSplice :: (HasCallStack, MonadIO m, IsListStore a) => a -> Word32 -> Word32 -> [Object] -> m ()
- constructListStoreItemType :: (IsListStore o, MonadIO m) => GType -> m (GValueConstruct o)
- getListStoreItemType :: (MonadIO m, IsListStore o) => o -> m GType
- getListStoreNItems :: (MonadIO m, IsListStore o) => o -> m Word32
Exported types
Memory-managed wrapper type.
Instances
Eq ListStore Source # | |
GObject ListStore Source # | |
Defined in GI.Gio.Objects.ListStore | |
ManagedPtrNewtype ListStore Source # | |
Defined in GI.Gio.Objects.ListStore | |
TypedObject ListStore Source # | |
Defined in GI.Gio.Objects.ListStore | |
HasParentTypes ListStore Source # | |
Defined in GI.Gio.Objects.ListStore | |
IsGValue (Maybe ListStore) Source # | Convert |
Defined in GI.Gio.Objects.ListStore | |
type ParentTypes ListStore Source # | |
Defined in GI.Gio.Objects.ListStore |
class (GObject o, IsDescendantOf ListStore o) => IsListStore o Source #
Type class for types which can be safely cast to ListStore
, for instance with toListStore
.
Instances
(GObject o, IsDescendantOf ListStore o) => IsListStore o Source # | |
Defined in GI.Gio.Objects.ListStore |
toListStore :: (MonadIO m, IsListStore o) => o -> m ListStore Source #
Methods
Click to display all available methods, including inherited ones
Methods
append, bindProperty, bindPropertyFull, find, findWithEqualFunc, findWithEqualFuncFull, forceFloating, freezeNotify, getv, insert, insertSorted, isFloating, itemsChanged, notify, notifyByPspec, ref, refSink, remove, removeAll, runDispose, sort, splice, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getItem, getItemType, getNItems, getProperty, getQdata.
Setters
append
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> b |
|
-> m () |
Appends item
to store
. item
must be of type ListStore:itemType.
This function takes a ref on item
.
Use listStoreSplice
to append multiple items at the same time
efficiently.
Since: 2.44
find
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> b |
|
-> m (Bool, Word32) | Returns: Whether |
Looks up the given item
in the list store by looping over the items until
the first occurrence of item
. If item
was not found, then position
will
not be set, and this method will return False
.
If you need to compare the two items with a custom comparison function, use
listStoreFindWithEqualFunc
with a custom EqualFunc
instead.
Since: 2.64
findWithEqualFunc
listStoreFindWithEqualFunc Source #
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> Maybe b |
|
-> EqualFunc |
|
-> m (Bool, Word32) | Returns: Whether |
Looks up the given item
in the list store by looping over the items and
comparing them with equalFunc
until the first occurrence of item
which
matches. If item
was not found, then position
will not be set, and this
method will return False
.
item
is always passed as second parameter to equalFunc
.
Since GLib 2.76 it is possible to pass NULL
for item
.
Since: 2.64
findWithEqualFuncFull
listStoreFindWithEqualFuncFull Source #
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> Maybe b |
|
-> EqualFuncFull |
|
-> m (Bool, Word32) | Returns: Whether |
Like listStoreFindWithEqualFunc
but with an additional userData
that is passed to equalFunc
.
item
is always passed as second parameter to equalFunc
.
Since GLib 2.76 it is possible to pass NULL
for item
.
Since: 2.74
insert
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> Word32 |
|
-> b |
|
-> m () |
Inserts item
into store
at position
. item
must be of type
ListStore:itemType or derived from it. position
must be smaller
than the length of the list, or equal to it to append.
This function takes a ref on item
.
Use listStoreSplice
to insert multiple items at the same time
efficiently.
Since: 2.44
insertSorted
listStoreInsertSorted Source #
:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) | |
=> a |
|
-> b |
|
-> CompareDataFunc |
|
-> m Word32 | Returns: the position at which |
Inserts item
into store
at a position to be determined by the
compareFunc
.
The list must already be sorted before calling this function or the result is undefined. Usually you would approach this by only ever inserting items by way of this function.
This function takes a ref on item
.
Since: 2.44
new
remove
:: (HasCallStack, MonadIO m, IsListStore a) | |
=> a |
|
-> Word32 |
|
-> m () |
Removes the item from store
that is at position
. position
must be
smaller than the current length of the list.
Use listStoreSplice
to remove multiple items at the same time
efficiently.
Since: 2.44
removeAll
:: (HasCallStack, MonadIO m, IsListStore a) | |
=> a |
|
-> m () |
Removes all items from store
.
Since: 2.44
sort
:: (HasCallStack, MonadIO m, IsListStore a) | |
=> a |
|
-> CompareDataFunc |
|
-> m () |
Sort the items in store
according to compareFunc
.
Since: 2.46
splice
:: (HasCallStack, MonadIO m, IsListStore a) | |
=> a |
|
-> Word32 |
|
-> Word32 |
|
-> [Object] |
|
-> m () |
Changes store
by removing nRemovals
items and adding nAdditions
items to it. additions
must contain nAdditions
items of type
ListStore:itemType. Nothing
is not permitted.
This function is more efficient than listStoreInsert
and
listStoreRemove
, because it only emits
ListModel::itemsChanged once for the change.
This function takes a ref on each item in additions
.
The parameters position
and nRemovals
must be correct (ie:
position
+ nRemovals
must be less than or equal to the length of
the list at the time this function is called).
Since: 2.44
Properties
itemType
The type of items contained in this list store. Items must be
subclasses of Object
.
Since: 2.44
constructListStoreItemType :: (IsListStore o, MonadIO m) => GType -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “item-type
” property. This is rarely needed directly, but it is used by new
.
getListStoreItemType :: (MonadIO m, IsListStore o) => o -> m GType Source #
Get the value of the “item-type
” property.
When overloading is enabled, this is equivalent to
get
listStore #itemType
nItems
The number of items contained in this list store.
Since: 2.74
getListStoreNItems :: (MonadIO m, IsListStore o) => o -> m Word32 Source #
Get the value of the “n-items
” property.
When overloading is enabled, this is equivalent to
get
listStore #nItems