From 64b022a5ed7acff0743d3fe1346a817b1eeeee8d Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 23 Dec 2020 12:54:12 +0300 Subject: [PATCH] [#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 --- pkg/services/object_manager/placement/netmap.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/services/object_manager/placement/netmap.go b/pkg/services/object_manager/placement/netmap.go index fcea1f4768..f5d3d30e76 100644 --- a/pkg/services/object_manager/placement/netmap.go +++ b/pkg/services/object_manager/placement/netmap.go @@ -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 +}