[#271] placement: Add FlattenNodes function

This function converts 2-dimension array of container nodes
into single dimension array. Useful when we need to iterate
over whole container.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-23 12:54:12 +03:00 committed by Alex Vanin
parent 58033a3adc
commit 64b022a5ed

View file

@ -58,3 +58,13 @@ func BuildObjectPlacement(nm *netmapSDK.Netmap, cnrNodes netmapSDK.ContainerNode
return on, nil return on, nil
} }
// FlattenNodes appends each row to the flat list.
func FlattenNodes(ns []netmapSDK.Nodes) netmapSDK.Nodes {
result := make(netmapSDK.Nodes, 0, len(ns))
for i := range ns {
result = append(result, ns[i]...)
}
return result
}