ILNumerics Ultimate VS

HelperFirstObjT Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Find and return the first matching object from the children of this group

[ILNumerics HDF5 Module]

Namespace:  ILNumerics.IO.HDF5
Assembly:  ILNumerics.IO.HDF5 (in ILNumerics.IO.HDF5.dll) Version: 5.5.0.0 (5.5.7503.3146)
Syntax

public static ObjT First<ObjT>(
	this H5Group root,
	string key = null,
	bool recursive = true,
	bool includeAttributes = false,
	Predicate<ObjT> predicate = null
)
where ObjT : H5Object

Parameters

root
Type: ILNumerics.IO.HDF5H5Group
the current root node of the set of children to search in
key (Optional)
Type: SystemString
[optional] if specified: the search term to filter the Name of the objects; default: match any name
recursive (Optional)
Type: SystemBoolean
[optional] true: search for the object recursively in the children of the current group. Default: true
includeAttributes (Optional)
Type: SystemBoolean
[optional] true: consider attributes as regular nodes, apply any matching rules to them; default: false
predicate (Optional)
Type: SystemPredicateObjT
[optional] if specified: the filter function used to determine a match; default: match any object

Type Parameters

ObjT
The (H5-) type of the object to search and return

Return Value

Type: ObjT
The first object matching all filters defined and the type of ObjT

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type H5Group. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks

This method allows the efficient retrieval of a specific object from a tree of H5Objects. The optional filter arguments may be used in order to delimit the set of considered objects. If used without any optional filter rules, First() returns the first object within the group or its children, which matches the type ObjT.

First() returns null, if no matching object was found.

No slashes are allowed for key.

Search order: if recursive is false, the children of the group are searched in the increasing order of their (HDF5) indices. That index is assigned by the HDF5 library at the time, the object was created in the file and added to the group. If recursive is true the subtree below root is traversed in breadth-first order, i.e.: the children of group are visited first, afterwards the children of the children a.s.o.

First() is based on Find() which does currently not handle cyclic references! Using First() on files which contain cyclic references may cause infinitely looping over the cycle, hence does not return anything!

[ILNumerics HDF5 Module]

Examples

In order to find the first dataset in the HDF5 file 'example.h5' with the name 'dset1':
using (var file = new H5File("example.h5")) {
    var dset = file.First<H5Dataset>("dset1");
    // do something with the dataset... read the data into an array:
    Array<double> A = dset.Get<double>(); 
    // ... 
}
Examples

In order to return all direct children of the first group named "group1" below this group:
using (var file = new H5File("example.h5")) {
    var children = file.First<H5Group>("group1").Find<H5Object>(recursive: false);
    // ... 
}
Examples

To find all datasets which contain "set" in the name:
using (var file = new H5File("example.h5")) {
    foreach (var ds in file.Find<H5Dataset>("set")) {
        // do something with the dataset ds ... read the data into an array:
        Array<double> A = ds.Get<double>(); 
        // ... 
    }
}
Examples

Get a list of the absolute paths of all objects below the 'root' group node:
using (var file = new H5File("example.h5")) {
    // H5Object is the base type of all common HDF5 objects in ILNumerics
    foreach (var obj in file.Find<H5Object>()) { 
        // write the absolute path of the object
        Console.WriteLine(obj.Path);  
    }
}
See Also

Reference