/// <summary>Adds a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <typeparam name="K">The type of the keys.</typeparam> /// <param name="trie">The trie to add the value to.</param> /// <param name="value">The value to be added.</param> /// <param name="stepper">The keys of the relative value.</param> public static void Add <T, K>(this ITrie <K, T> trie, T value, Stepper <K> stepper) { if (!trie.TryAdd(value, stepper, out Exception exception)) { throw exception; } }
/// <summary>Adds a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <typeparam name="TData">The type of the data.</typeparam> /// <param name="trie">The trie to add the value to.</param> /// <param name="value">The value to be added.</param> /// <param name="stepper">The keys of the relative value.</param> public static void Add <T, TData>(this ITrie <T, TData> trie, TData value, Action <Action <T> > stepper) { var(success, exception) = trie.TryAdd(value, stepper); if (!success) { throw exception ?? new ArgumentException($"{nameof(Add)} failed but the {nameof(exception)} is null"); } }
/// <summary>Adds a value.</summary> /// <typeparam name="T">The type of value.</typeparam> /// <typeparam name="K">The type of the keys.</typeparam> /// <param name="trie">The trie to add the value to.</param> /// <param name="value">The value to be added.</param> /// <param name="stepper">The keys of the relative value.</param> /// <returns>True if the add was successful or false if not.</returns> public static bool TryAdd <K, T>(this ITrie <K, T> trie, T value, Stepper <K> stepper) => trie.TryAdd(value, stepper, out _);