forked from TrueCloudLab/frostfs-node
[#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:
parent
58033a3adc
commit
64b022a5ed
1 changed files with 10 additions and 0 deletions
|
@ -58,3 +58,13 @@ func BuildObjectPlacement(nm *netmapSDK.Netmap, cnrNodes netmapSDK.ContainerNode
|
|||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue