コード例 #1
0
 /// <summary>Wrapper for the get function to handle exceptions.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <typeparam name="Key">The type of the key.</typeparam>
 /// <param name="avlTree">This structure.</param>
 /// <param name="key">The key to get.</param>
 /// <param name="comparison">The sorting technique (must synchronize with this structure's sorting).</param>
 /// <param name="item">The item if found.</param>
 /// <returns>True if successful, False if not.</returns>
 public static bool TryGet <T, Key>(this IAvlTree <T> avlTree, Key key, Compare <T, Key> compare, out T item)
 {
     try
     {
         item = avlTree.Get <Key>(key, compare);
         return(true);
     }
     catch
     {
         item = default(T);
         return(false);
     }
 }
コード例 #2
0
ファイル: AvlTree.cs プロジェクト: ShiftLeftSecurity/Towel
 /// <summary>Wrapper for the get function to handle exceptions.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="avlTree">This structure.</param>
 /// <param name="compare">The sorting technique (must synchronize with this structure's sorting).</param>
 /// <param name="item">The item if found.</param>
 /// <returns>True if successful, False if not.</returns>
 public static bool TryGet <T>(this IAvlTree <T> avlTree, CompareToKnownValue <T> compare, out T item)
 {
     try
     {
         item = avlTree.Get(compare);
         return(true);
     }
     catch
     {
         item = default(T);
         return(false);
     }
 }