gi-gio-2.0.25: Gio bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Objects.ListStore

Description

ListStore 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

Exported types

newtype ListStore Source #

Memory-managed wrapper type.

Instances

Instances details
Eq ListStore Source # 
Instance details

Defined in GI.Gio.Objects.ListStore

GObject ListStore Source # 
Instance details

Defined in GI.Gio.Objects.ListStore

Methods

gobjectType :: IO GType #

IsGValue ListStore Source #

Convert ListStore to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gio.Objects.ListStore

HasParentTypes ListStore Source # 
Instance details

Defined in GI.Gio.Objects.ListStore

type ParentTypes ListStore Source # 
Instance details

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

Instances details
(GObject o, IsDescendantOf ListStore o) => IsListStore o Source # 
Instance details

Defined in GI.Gio.Objects.ListStore

toListStore :: (MonadIO m, IsListStore o) => o -> m ListStore Source #

Cast to ListStore, for types for which this is known to be safe. For general casts, use castTo.

noListStore :: Maybe ListStore Source #

A convenience alias for Nothing :: Maybe ListStore.

Methods

Overloaded methods

append

listStoreAppend Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) 
=> a

store: a ListStore

-> b

item: the new item

-> m () 

Appends item to store. item must be of type ListStore:item-type.

This function takes a ref on item.

Use listStoreSplice to append multiple items at the same time efficiently.

Since: 2.44

insert

listStoreInsert Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) 
=> a

store: a ListStore

-> Word32

position: the position at which to insert the new item

-> b

item: the new item

-> m () 

Inserts item into store at position. item must be of type ListStore:item-type 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 #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a, IsObject b) 
=> a

store: a ListStore

-> b

item: the new item

-> CompareDataFunc

compareFunc: pairwise comparison function for sorting

-> m Word32

Returns: the position at which item was inserted

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

listStoreNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> GType

itemType: the GType of items in the list

-> m ListStore

Returns: a new ListStore

Creates a new ListStore with items of type itemType. itemType must be a subclass of Object.

Since: 2.44

remove

listStoreRemove Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a) 
=> a

store: a ListStore

-> Word32

position: the position of the item that is to be removed

-> 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

listStoreRemoveAll Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a) 
=> a

store: a ListStore

-> m () 

Removes all items from store.

Since: 2.44

sort

listStoreSort Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a) 
=> a

store: a ListStore

-> CompareDataFunc

compareFunc: pairwise comparison function for sorting

-> m () 

Sort the items in store according to compareFunc.

Since: 2.46

splice

listStoreSplice Source #

Arguments

:: (HasCallStack, MonadIO m, IsListStore a) 
=> a

store: a ListStore

-> Word32

position: the position at which to make the change

-> Word32

nRemovals: the number of items to remove

-> [Object]

additions: the items to add

-> m () 

Changes store by removing nRemovals items and adding nAdditions items to it. additions must contain nAdditions items of type ListStore:item-type. Nothing is not permitted.

This function is more efficient than listStoreInsert and listStoreRemove, because it only emits 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 => GType -> IO (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