A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

65 lines
1.8 KiB

// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
/*
Copyright 2007-2013 The NGenerics Team
(https://github.com/ngenerics/ngenerics/wiki/Team)
This program is licensed under the GNU Lesser General Public License (LGPL). You should
have received a copy of the license along with the source code. If not, an online copy
of the license can be found at http://www.gnu.org/copyleft/lesser.html.
*/
using System.Collections.Generic;
namespace NGenerics.Patterns.Visitor
{
/// <summary>
/// A visitor that tracks (stores) keys from KeyValuePAirs in the order they were visited.
/// </summary>
/// <typeparam name="TKey">The type of the keys for the items to be visited.</typeparam>
/// <typeparam name="TValue">The type of the values for the items to be visited.</typeparam>
public sealed class KeyTrackingVisitor<TKey, TValue> : IVisitor<KeyValuePair<TKey, TValue>>
{
#region Globals
private readonly List<TKey> _tracks;
#endregion
#region Construction
/// <inheritdoc/>
public KeyTrackingVisitor()
{
_tracks = new List<TKey>();
}
#endregion
#region Public Members
/// <summary>
/// Gets the tracking list.
/// </summary>
/// <value>The tracking list.</value>
public IList<TKey> TrackingList => _tracks;
#endregion
#region IVisitor<KeyValuePair<TKey,TValue>> Members
/// <inheritdoc />
public void Visit(KeyValuePair<TKey, TValue> obj)
{
_tracks.Add(obj.Key);
}
/// <inheritdoc />
public bool HasCompleted => false;
#endregion
}
}