gi-glib-2.0.29: GLib bindings

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

GI.GLib.Structs.Node

Contents

- Exported types
- Methods
  - childIndex
  - childPosition
  - childrenForeach
  - depth
  - destroy
  - isAncestor
  - maxHeight
  - nChildren
  - nNodes
  - popAllocator
  - pushAllocator
  - reverseChildren
  - traverse
  - unlink
- Properties
  - children
  - data
  - next
  - parent
  - prev

Description

The `Node` struct represents one node in a [n-ary tree][glib-N-ary-Trees].

Synopsis

- newtype Node = Node (ManagedPtr Node)
- newZeroNode :: MonadIO m => m Node
- nodeChildIndex :: (HasCallStack, MonadIO m) => Node -> Ptr () -> m Int32
- nodeChildPosition :: (HasCallStack, MonadIO m) => Node -> Node -> m Int32
- nodeChildrenForeach :: (HasCallStack, MonadIO m) => Node -> [TraverseFlags] -> NodeForeachFunc -> m ()
- nodeDepth :: (HasCallStack, MonadIO m) => Node -> m Word32
- nodeDestroy :: (HasCallStack, MonadIO m) => Node -> m ()
- nodeIsAncestor :: (HasCallStack, MonadIO m) => Node -> Node -> m Bool
- nodeMaxHeight :: (HasCallStack, MonadIO m) => Node -> m Word32
- nodeNChildren :: (HasCallStack, MonadIO m) => Node -> m Word32
- nodeNNodes :: (HasCallStack, MonadIO m) => Node -> [TraverseFlags] -> m Word32
- nodePopAllocator :: (HasCallStack, MonadIO m) => m ()
- nodePushAllocator :: (HasCallStack, MonadIO m) => Allocator -> m ()
- nodeReverseChildren :: (HasCallStack, MonadIO m) => Node -> m ()
- nodeTraverse :: (HasCallStack, MonadIO m) => Node -> TraverseType -> [TraverseFlags] -> Int32 -> NodeTraverseFunc -> m ()
- nodeUnlink :: (HasCallStack, MonadIO m) => Node -> m ()
- clearNodeChildren :: MonadIO m => Node -> m ()
- getNodeChildren :: MonadIO m => Node -> m (Maybe Node)
- setNodeChildren :: MonadIO m => Node -> Ptr Node -> m ()
- clearNodeData :: MonadIO m => Node -> m ()
- getNodeData :: MonadIO m => Node -> m (Ptr ())
- setNodeData :: MonadIO m => Node -> Ptr () -> m ()
- clearNodeNext :: MonadIO m => Node -> m ()
- getNodeNext :: MonadIO m => Node -> m (Maybe Node)
- setNodeNext :: MonadIO m => Node -> Ptr Node -> m ()
- clearNodeParent :: MonadIO m => Node -> m ()
- getNodeParent :: MonadIO m => Node -> m (Maybe Node)
- setNodeParent :: MonadIO m => Node -> Ptr Node -> m ()
- clearNodePrev :: MonadIO m => Node -> m ()
- getNodePrev :: MonadIO m => Node -> m (Maybe Node)
- setNodePrev :: MonadIO m => Node -> Ptr Node -> m ()

# Exported types

newtype Node Source #

Memory-managed wrapper type.

Constructors

Node (ManagedPtr Node) |

#### Instances

Instances details

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

newZeroNode :: MonadIO m => m Node Source #

Construct a `Node` struct initialized to zero.

# Methods

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

Expand

#### Methods

childIndex, childPosition, childrenForeach, depth, destroy, isAncestor, maxHeight, nChildren, nNodes, reverseChildren, traverse, unlink.

#### Getters

None.

#### Setters

None.

## childIndex

nodeChildIndex Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> Ptr () | `data`: the data to find
-> m Int32 | Returns: the index of the child of `node` which contains `data`, or -1 if the data is not found

Gets the position of the first child of a `Node` which contains the given data.

## childPosition

nodeChildPosition Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> Node | `child`: a child of `node`
-> m Int32 | Returns: the position of `child` with respect to its siblings

Gets the position of a `Node` with respect to its siblings. `child` must be a child of `node`. The first child is numbered 0, the second 1, and so on.

## childrenForeach

nodeChildrenForeach Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> [TraverseFlags] | `flags`: which types of children are to be visited, one of `TraverseFlagsAll`, `TraverseFlagsLeaves` and `TraverseFlagsNonLeaves`
-> NodeForeachFunc | `func`: the function to call for each visited node
-> m () |

Calls a function for each of the children of a `Node`. Note that it doesn't descend beneath the child nodes. `func` must not do anything that would modify the structure of the tree.

## depth

nodeDepth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> m Word32 | Returns: the depth of the `Node`

Gets the depth of a `Node`.

If `node` is `Nothing` the depth is 0. The root node has a depth of 1. For the children of the root node the depth is 2. And so on.

## destroy

nodeDestroy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `root`: the root of the tree/subtree to destroy
-> m () |

Removes `root` and its children from the tree, freeing any memory allocated.

## isAncestor

nodeIsAncestor Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> Node | `descendant`: a `Node`
-> m Bool | Returns: `True` if `node` is an ancestor of `descendant`

Returns `True` if `node` is an ancestor of `descendant`. This is true if node is the parent of `descendant`, or if node is the grandparent of `descendant` etc.

## maxHeight

nodeMaxHeight Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `root`: a `Node`
-> m Word32 | Returns: the maximum height of the tree beneath `root`

Gets the maximum height of all branches beneath a `Node`. This is the maximum distance from the `Node` to all leaf nodes.

If `root` is `Nothing`, 0 is returned. If `root` has no children, 1 is returned. If `root` has children, 2 is returned. And so on.

## nChildren

nodeNChildren Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`
-> m Word32 | Returns: the number of children of `node`

Gets the number of children of a `Node`.

## nNodes

nodeNNodes Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `root`: a `Node`
-> [TraverseFlags] | `flags`: which types of children are to be counted, one of `TraverseFlagsAll`, `TraverseFlagsLeaves` and `TraverseFlagsNonLeaves`
-> m Word32 | Returns: the number of nodes in the tree

Gets the number of nodes in a tree.

## popAllocator

nodePopAllocator :: (HasCallStack, MonadIO m) => m () Source #

No description available in the introspection data.

## pushAllocator

nodePushAllocator :: (HasCallStack, MonadIO m) => Allocator -> m () Source #

No description available in the introspection data.

## reverseChildren

nodeReverseChildren Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: a `Node`.
-> m () |

Reverses the order of the children of a `Node`. (It doesn't change the order of the grandchildren.)

## traverse

nodeTraverse Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `root`: the root `Node` of the tree to traverse
-> TraverseType | `order`: the order in which nodes are visited - `TraverseTypeInOrder`, `TraverseTypePreOrder`, `TraverseTypePostOrder`, or `TraverseTypeLevelOrder`.
-> [TraverseFlags] | `flags`: which types of children are to be visited, one of `TraverseFlagsAll`, `TraverseFlagsLeaves` and `TraverseFlagsNonLeaves`
-> Int32 | `maxDepth`: the maximum depth of the traversal. Nodes below this depth will not be visited. If max_depth is -1 all nodes in the tree are visited. If depth is 1, only the root is visited. If depth is 2, the root and its children are visited. And so on.
-> NodeTraverseFunc | `func`: the function to call for each visited `Node`
-> m () |

Traverses a tree starting at the given root `Node`. It calls the given function for each node visited. The traversal can be halted at any point by returning `True` from `func`. `func` must not do anything that would modify the structure of the tree.

## unlink

nodeUnlink Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Node | `node`: the `Node` to unlink, which becomes the root of a new tree
-> m () |

Unlinks a `Node` from a tree, resulting in two separate trees.

# Properties

## children

points to the first child of the `Node`. The other children are accessed by using the `next` pointer of each child.

clearNodeChildren :: MonadIO m => Node -> m () Source #

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

    clear #children

getNodeChildren :: MonadIO m => Node -> m (Maybe Node) Source #

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

    get node #children

setNodeChildren :: MonadIO m => Node -> Ptr Node -> m () Source #

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

    set node [ #children := value ]

## data

contains the actual data of the node.

clearNodeData :: MonadIO m => Node -> m () Source #

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

    clear #data

getNodeData :: MonadIO m => Node -> m (Ptr ()) Source #

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

    get node #data

setNodeData :: MonadIO m => Node -> Ptr () -> m () Source #

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

    set node [ #data := value ]

## next

points to the node's next sibling (a sibling is another `Node` with the same parent).

clearNodeNext :: MonadIO m => Node -> m () Source #

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

    clear #next

getNodeNext :: MonadIO m => Node -> m (Maybe Node) Source #

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

    get node #next

setNodeNext :: MonadIO m => Node -> Ptr Node -> m () Source #

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

    set node [ #next := value ]

## parent

points to the parent of the `Node`, or is `Nothing` if the `Node` is the root of the tree.

clearNodeParent :: MonadIO m => Node -> m () Source #

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

    clear #parent

getNodeParent :: MonadIO m => Node -> m (Maybe Node) Source #

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

    get node #parent

setNodeParent :: MonadIO m => Node -> Ptr Node -> m () Source #

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

    set node [ #parent := value ]

## prev

points to the node's previous sibling.

clearNodePrev :: MonadIO m => Node -> m () Source #

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

    clear #prev

getNodePrev :: MonadIO m => Node -> m (Maybe Node) Source #

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

    get node #prev

setNodePrev :: MonadIO m => Node -> Ptr Node -> m () Source #

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

    set node [ #prev := value ]