ILNumerics Ultimate VS

HelperFindTObjT Method

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Finds any matching object among 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 IEnumerable<TObjT> Find<TObjT>(
	this H5Group root,
	string key = null,
	bool recursive = true,
	bool includeAttributes = false,
	Predicate<TObjT> predicate = null
)
where TObjT : 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 objects by Name; default: match any name
recursive (Optional)
Type: SystemBoolean
[optional] if true: searches for objects recursively in the children of the current group. Default: true
includeAttributes (Optional)
Type: SystemBoolean
[optional] if true: consider attributes as regular nodes, apply any matching rules to them; default: false
predicate (Optional)
Type: SystemPredicateTObjT
[optional] if specified: the filter function used to determine a match; default: match any object

Type Parameters

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

Return Value

Type: IEnumerableTObjT
Enumerable with all objects of type TObjT matching all filter criteria defined

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 specific objects from the tree of H5Objects below an HDF5 group. The optional filter arguments may be used to delimit the set of considered objects. If used without any optional filter rules, Find() returns all the objects of the given type TObjT within the group or its children, which matches the type TObjT.

No slashes are allowed for key.

Search order: if recursive is false, the children of the group are walked by 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 (default) the subtree below root is traversed in breadth-first order, i.e.: the root is visited before the children are visited, afterwards the children of the children a.s.o.

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

[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>(); 
                // ... 
            }
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);
                // ... 
            }
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>(); 
                    // ... 
                }
            }
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