gi-glib-2.0.30: GLib bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.GLib.Structs.Queue

Contents

- Exported types
- Methods
  - clear
  - clearFull
  - foreach
  - free
  - freeFull
  - getLength
  - index
  - init
  - insertSorted
  - isEmpty
  - peekHead
  - peekNth
  - peekTail
  - popHead
  - popNth
  - popTail
  - pushHead
  - pushNth
  - pushTail
  - remove
  - removeAll
  - reverse
  - sort
- Properties
  - head
  - length
  - tail

Description

Contains the public fields of a Queue.

Synopsis

- newtype Queue = Queue (ManagedPtr Queue)
- newZeroQueue :: MonadIO m => m Queue
- queueClear :: (HasCallStack, MonadIO m) => Queue -> m ()
- queueClearFull :: (HasCallStack, MonadIO m) => Queue -> Maybe DestroyNotify -> m ()
- queueForeach :: (HasCallStack, MonadIO m) => Queue -> Func -> m ()
- queueFree :: (HasCallStack, MonadIO m) => Queue -> m ()
- queueFreeFull :: (HasCallStack, MonadIO m) => Queue -> DestroyNotify -> m ()
- queueGetLength :: (HasCallStack, MonadIO m) => Queue -> m Word32
- queueIndex :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> m Int32
- queueInit :: (HasCallStack, MonadIO m) => Queue -> m ()
- queueInsertSorted :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> CompareDataFunc -> m ()
- queueIsEmpty :: (HasCallStack, MonadIO m) => Queue -> m Bool
- queuePeekHead :: (HasCallStack, MonadIO m) => Queue -> m (Ptr ())
- queuePeekNth :: (HasCallStack, MonadIO m) => Queue -> Word32 -> m (Ptr ())
- queuePeekTail :: (HasCallStack, MonadIO m) => Queue -> m (Ptr ())
- queuePopHead :: (HasCallStack, MonadIO m) => Queue -> m (Ptr ())
- queuePopNth :: (HasCallStack, MonadIO m) => Queue -> Word32 -> m (Ptr ())
- queuePopTail :: (HasCallStack, MonadIO m) => Queue -> m (Ptr ())
- queuePushHead :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> m ()
- queuePushNth :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> Int32 -> m ()
- queuePushTail :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> m ()
- queueRemove :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> m Bool
- queueRemoveAll :: (HasCallStack, MonadIO m) => Queue -> Ptr () -> m Word32
- queueReverse :: (HasCallStack, MonadIO m) => Queue -> m ()
- queueSort :: (HasCallStack, MonadIO m) => Queue -> CompareDataFunc -> m ()
- clearQueueHead :: MonadIO m => Queue -> m ()
- getQueueHead :: MonadIO m => Queue -> m [Ptr ()]
- setQueueHead :: MonadIO m => Queue -> Ptr (GList (Ptr ())) -> m ()
- getQueueLength :: MonadIO m => Queue -> m Word32
- setQueueLength :: MonadIO m => Queue -> Word32 -> m ()
- clearQueueTail :: MonadIO m => Queue -> m ()
- getQueueTail :: MonadIO m => Queue -> m [Ptr ()]
- setQueueTail :: MonadIO m => Queue -> Ptr (GList (Ptr ())) -> m ()

# Exported types

newtype Queue Source #

Memory-managed wrapper type.

Constructors

Queue (ManagedPtr Queue) |

#### Instances

Instances details

Eq Queue Source # |
Instance details Defined in GI.GLib.Structs.Queue Methods (==) :: Queue -> Queue -> Bool Source # (/=) :: Queue -> Queue -> Bool Source #
BoxedPtr Queue Source # |
Instance details Defined in GI.GLib.Structs.Queue Methods boxedPtrCopy :: Queue -> IO Queue Source # boxedPtrFree :: Queue -> IO () Source #
CallocPtr Queue Source # |
Instance details Defined in GI.GLib.Structs.Queue Methods boxedPtrCalloc :: IO (Ptr Queue) Source #
ManagedPtrNewtype Queue Source # |
Instance details Defined in GI.GLib.Structs.Queue Methods toManagedPtr :: Queue -> ManagedPtr Queue Source #
tag ~ 'AttrSet => Constructible Queue tag Source # |
Instance details Defined in GI.GLib.Structs.Queue Methods new :: MonadIO m => (ManagedPtr Queue -> Queue) -> [AttrOp Queue tag] -> m Queue Source #

newZeroQueue :: MonadIO m => m Queue Source #

Construct a `Queue` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

clear, clearFull, foreach, free, freeFull, index, init, insertSorted, isEmpty, peekHead, peekNth, peekTail, popHead, popNth, popTail, pushHead, pushNth, pushTail, remove, removeAll, reverse, sort.

#### Getters

getLength.

#### Setters

None.

## clear

queueClear Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m () |

Removes all the elements in `queue`. If queue elements contain dynamically-allocated memory, they should be freed first.

Since: 2.14

## clearFull

queueClearFull Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a pointer to a `Queue`
-> Maybe DestroyNotify | `freeFunc`: the function to be called to free memory allocated
-> m () |

Convenience method, which frees all the memory used by a `Queue`, and calls the provided `freeFunc` on each item in the `Queue`.

Since: 2.60

## foreach

queueForeach Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Func | `func`: the function to call for each element's data
-> m () |

Calls `func` for each element in the queue passing `userData` to the function.

It is safe for `func` to remove the element from `queue`, but it must not modify any part of the queue after that element.

Since: 2.4

## free

queueFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m () |

Frees the memory allocated for the `Queue`. Only call this function if `queue` was created with `g_queue_new()`. If queue elements contain dynamically-allocated memory, they should be freed first.

If queue elements contain dynamically-allocated memory, you should either use `queueFreeFull` or free them manually first.

## freeFull

queueFreeFull Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a pointer to a `Queue`
-> DestroyNotify | `freeFunc`: the function to be called to free each element's data
-> m () |

Convenience method, which frees all the memory used by a `Queue`, and calls the specified destroy function on every element's data.

`freeFunc` should not modify the queue (eg, by removing the freed element from it).

Since: 2.32

## getLength

queueGetLength Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m Word32 | Returns: the number of items in `queue`

Returns the number of items in `queue`.

Since: 2.4

## index

queueIndex Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data to find
-> m Int32 | Returns: the position of the first element in `queue` which contains `data`, or -1 if no element in `queue` contains `data`

Returns the position of the first element in `queue` which contains `data`.

Since: 2.4

## init

queueInit Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: an uninitialized `Queue`
-> m () |

A statically-allocated `Queue` must be initialized with this function before it can be used. Alternatively you can initialize it with `G_QUEUE_INIT`. It is not necessary to initialize queues created with `g_queue_new()`.

Since: 2.14

## insertSorted

queueInsertSorted Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data to insert
-> CompareDataFunc | `func`: the `CompareDataFunc` used to compare elements in the queue. It is called with two elements of the `queue` and `userData`. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.
-> m () |

Inserts `data` into `queue` using `func` to determine the new position.

Since: 2.4

## isEmpty

queueIsEmpty Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`.
-> m Bool | Returns: `True` if the queue is empty

Returns `True` if the queue is empty.

## peekHead

queuePeekHead Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m (Ptr ()) | Returns: the data of the first element in the queue, or `Nothing` if the queue is empty

Returns the first element of the queue.

## peekNth

queuePeekNth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Word32 | `n`: the position of the element
-> m (Ptr ()) | Returns: the data for the `n`'th element of `queue`, or `Nothing` if `n` is off the end of `queue`

Returns the `n`'th element of `queue`.

Since: 2.4

## peekTail

queuePeekTail Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m (Ptr ()) | Returns: the data of the last element in the queue, or `Nothing` if the queue is empty

Returns the last element of the queue.

## popHead

queuePopHead Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m (Ptr ()) | Returns: the data of the first element in the queue, or `Nothing` if the queue is empty

Removes the first element of the queue and returns its data.

## popNth

queuePopNth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Word32 | `n`: the position of the element
-> m (Ptr ()) | Returns: the element's data, or `Nothing` if `n` is off the end of `queue`

Removes the `n`'th element of `queue` and returns its data.

Since: 2.4

## popTail

queuePopTail Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m (Ptr ()) | Returns: the data of the last element in the queue, or `Nothing` if the queue is empty

Removes the last element of the queue and returns its data.

## pushHead

queuePushHead Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`.
-> Ptr () | `data`: the data for the new element.
-> m () |

Adds a new element at the head of the queue.

## pushNth

queuePushNth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data for the new element
-> Int32 | `n`: the position to insert the new element. If `n` is negative or larger than the number of elements in the `queue`, the element is added to the end of the queue.
-> m () |

Inserts a new element into `queue` at the given position.

Since: 2.4

## pushTail

queuePushTail Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data for the new element
-> m () |

Adds a new element at the tail of the queue.

## remove

queueRemove Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data to remove
-> m Bool | Returns: `True` if `data` was found and removed from `queue`

Removes the first element in `queue` that contains `data`.

Since: 2.4

## removeAll

queueRemoveAll Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> Ptr () | `data`: the data to remove
-> m Word32 | Returns: the number of elements removed from `queue`

Remove all elements whose data equals `data` from `queue`.

Since: 2.4

## reverse

queueReverse Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> m () |

Reverses the order of the items in `queue`.

Since: 2.4

## sort

queueSort Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Queue | `queue`: a `Queue`
-> CompareDataFunc | `compareFunc`: the `CompareDataFunc` used to sort `queue`. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.
-> m () |

Sorts `queue` using `compareFunc`.

Since: 2.4

# Properties

## head

a pointer to the first element of the queue

clearQueueHead :: MonadIO m => Queue -> m () Source #

Set the value of the “`head`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #head

getQueueHead :: MonadIO m => Queue -> m [Ptr ()] Source #

Get the value of the “`head`” field. When overloading is enabled, this is equivalent to

    get queue #head

setQueueHead :: MonadIO m => Queue -> Ptr (GList (Ptr ())) -> m () Source #

Set the value of the “`head`” field. When overloading is enabled, this is equivalent to

    set queue [ #head := value ]

## length

the number of elements in the queue

getQueueLength :: MonadIO m => Queue -> m Word32 Source #

Get the value of the “`length`” field. When overloading is enabled, this is equivalent to

    get queue #length

setQueueLength :: MonadIO m => Queue -> Word32 -> m () Source #

Set the value of the “`length`” field. When overloading is enabled, this is equivalent to

    set queue [ #length := value ]

## tail

a pointer to the last element of the queue

clearQueueTail :: MonadIO m => Queue -> m () Source #

Set the value of the “`tail`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #tail

getQueueTail :: MonadIO m => Queue -> m [Ptr ()] Source #

Get the value of the “`tail`” field. When overloading is enabled, this is equivalent to

    get queue #tail

setQueueTail :: MonadIO m => Queue -> Ptr (GList (Ptr ())) -> m () Source #

Set the value of the “`tail`” field. When overloading is enabled, this is equivalent to

    set queue [ #tail := value ]