ResourceMirror.Sync<ItemType,ResourceType> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Given a sorted list of source data items (currentItems), and a sorted list of resources: For each source item that doesn't have a matching resource, attempt to create a resource. For each resource that doesn't have a matching source item, destroy that resource. For each source item with a matching resource, update the resource.
public static void Sync<ItemType,ResourceType> (System.Collections.Generic.IReadOnlyList<ItemType> currentItems, System.Collections.Generic.List<ResourceType> resources, Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.CompareToResource<ItemType,ResourceType> compareIds, Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.CreateResource<ItemType,ResourceType> creator, Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.UpdateResource<ItemType,ResourceType> updater, Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.DestroyResource<ResourceType> destroyer);
static member Sync : System.Collections.Generic.IReadOnlyList<'ItemType> * System.Collections.Generic.List<'ResourceType> * Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.CompareToResource<'ItemType, 'ResourceType> * Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.CreateResource<'ItemType, 'ResourceType> * Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.UpdateResource<'ItemType, 'ResourceType> * Microsoft.MixedReality.WorldLocking.Core.ResourceMirror.DestroyResource<'ResourceType> -> unit
Public Shared Sub Sync(Of ItemType, ResourceType) (currentItems As IReadOnlyList(Of ItemType), resources As List(Of ResourceType), compareIds As ResourceMirror.CompareToResource(Of ItemType, ResourceType), creator As ResourceMirror.CreateResource(Of ItemType, ResourceType), updater As ResourceMirror.UpdateResource(Of ItemType, ResourceType), destroyer As ResourceMirror.DestroyResource(Of ResourceType))
Type Parameters
- ItemType
Type of source items.
- ResourceType
Type of resources.
Parameters
- currentItems
- IReadOnlyList<ItemType>
List of current source items.
- resources
- List<ResourceType>
List of resources to by synced to currentItems.
Function to compare an item with a resource. See above.
Callback to create a missing resource. See above.
Callback to update an existing resource. See above.
Callback to destroy a resource which no longer has a matching source item.
Remarks
After this Sync, the list of resources will have exactly one resource for each item in currentItems, and currentItems and resources will be the same length. The exception is if the creator function returns false for any item(s), then those item(s) will not have matching resources, and resources will be shorter than currentItems. In any case, resources will remain sorted. Sync completes in a single pass over the data, so in O(max(currentItems.Count, resources.Count)) time.