PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/Mono.C5/C5/Interfaces.cs

https://bitbucket.org/danipen/mono
C# | 2059 lines | 270 code | 312 blank | 1477 comment | 0 complexity | acad36844a521f3d20e032808784f8f1 MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.
  18. */
  19. using System;
  20. using SCG = System.Collections.Generic;
  21. namespace C5
  22. {
  23. /// <summary>
  24. /// A generic collection, that can be enumerated backwards.
  25. /// </summary>
  26. public interface IDirectedEnumerable<T> : SCG.IEnumerable<T>
  27. {
  28. /// <summary>
  29. /// Create a collection containing the same items as this collection, but
  30. /// whose enumerator will enumerate the items backwards. The new collection
  31. /// will become invalid if the original is modified. Method typically used as in
  32. /// <code>foreach (T x in coll.Backwards()) {...}</code>
  33. /// </summary>
  34. /// <returns>The backwards collection.</returns>
  35. IDirectedEnumerable<T> Backwards();
  36. /// <summary>
  37. /// <code>Forwards</code> if same, else <code>Backwards</code>
  38. /// </summary>
  39. /// <value>The enumeration direction relative to the original collection.</value>
  40. EnumerationDirection Direction { get;}
  41. }
  42. /// <summary>
  43. /// A generic collection that may be enumerated and can answer
  44. /// efficiently how many items it contains. Like <code>IEnumerable&lt;T&gt;</code>,
  45. /// this interface does not prescribe any operations to initialize or update the
  46. /// collection. The main usage for this interface is to be the return type of
  47. /// query operations on generic collection.
  48. /// </summary>
  49. public interface ICollectionValue<T> : SCG.IEnumerable<T>, IShowable
  50. {
  51. /// <summary>
  52. /// A flag bitmap of the events subscribable to by this collection.
  53. /// </summary>
  54. /// <value></value>
  55. EventTypeEnum ListenableEvents { get;}
  56. /// <summary>
  57. /// A flag bitmap of the events currently subscribed to by this collection.
  58. /// </summary>
  59. /// <value></value>
  60. EventTypeEnum ActiveEvents { get;}
  61. /// <summary>
  62. /// The change event. Will be raised for every change operation on the collection.
  63. /// </summary>
  64. event CollectionChangedHandler<T> CollectionChanged;
  65. /// <summary>
  66. /// The change event. Will be raised for every clear operation on the collection.
  67. /// </summary>
  68. event CollectionClearedHandler<T> CollectionCleared;
  69. /// <summary>
  70. /// The item added event. Will be raised for every individual addition to the collection.
  71. /// </summary>
  72. event ItemsAddedHandler<T> ItemsAdded;
  73. /// <summary>
  74. /// The item inserted event. Will be raised for every individual insertion to the collection.
  75. /// </summary>
  76. event ItemInsertedHandler<T> ItemInserted;
  77. /// <summary>
  78. /// The item removed event. Will be raised for every individual removal from the collection.
  79. /// </summary>
  80. event ItemsRemovedHandler<T> ItemsRemoved;
  81. /// <summary>
  82. /// The item removed at event. Will be raised for every individual removal at from the collection.
  83. /// </summary>
  84. event ItemRemovedAtHandler<T> ItemRemovedAt;
  85. /// <summary>
  86. ///
  87. /// </summary>
  88. /// <value>True if this collection is empty.</value>
  89. bool IsEmpty { get;}
  90. /// <summary>
  91. /// </summary>
  92. /// <value>The number of items in this collection</value>
  93. int Count { get;}
  94. /// <summary>
  95. /// The value is symbolic indicating the type of asymptotic complexity
  96. /// in terms of the size of this collection (worst-case or amortized as
  97. /// relevant).
  98. /// </summary>
  99. /// <value>A characterization of the speed of the
  100. /// <code>Count</code> property in this collection.</value>
  101. Speed CountSpeed { get;}
  102. /// <summary>
  103. /// Copy the items of this collection to a contiguous part of an array.
  104. /// </summary>
  105. /// <param name="array">The array to copy to</param>
  106. /// <param name="index">The index at which to copy the first item</param>
  107. void CopyTo(T[] array, int index);
  108. /// <summary>
  109. /// Create an array with the items of this collection (in the same order as an
  110. /// enumerator would output them).
  111. /// </summary>
  112. /// <returns>The array</returns>
  113. T[] ToArray();
  114. /// <summary>
  115. /// Apply a delegate to all items of this collection.
  116. /// </summary>
  117. /// <param name="action">The delegate to apply</param>
  118. void Apply(Act<T> action);
  119. /// <summary>
  120. /// Check if there exists an item that satisfies a
  121. /// specific predicate in this collection.
  122. /// </summary>
  123. /// <param name="predicate">A delegate
  124. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  125. /// <returns>True is such an item exists</returns>
  126. bool Exists(Fun<T, bool> predicate);
  127. /// <summary>
  128. /// Check if there exists an item that satisfies a
  129. /// specific predicate in this collection and return the first one in enumeration order.
  130. /// </summary>
  131. /// <param name="predicate">A delegate
  132. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  133. /// <param name="item"></param>
  134. /// <returns>True is such an item exists</returns>
  135. bool Find(Fun<T, bool> predicate, out T item);
  136. /// <summary>
  137. /// Check if all items in this collection satisfies a specific predicate.
  138. /// </summary>
  139. /// <param name="predicate">A delegate
  140. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  141. /// <returns>True if all items satisfies the predicate</returns>
  142. bool All(Fun<T, bool> predicate);
  143. /// <summary>
  144. /// Choose some item of this collection.
  145. /// <para>Implementations must assure that the item
  146. /// returned may be efficiently removed.</para>
  147. /// <para>Implementors may decide to implement this method in a way such that repeated
  148. /// calls do not necessarily give the same result, i.e. so that the result of the following
  149. /// test is undetermined:
  150. /// <code>coll.Choose() == coll.Choose()</code></para>
  151. /// </summary>
  152. /// <exception cref="NoSuchItemException">if collection is empty.</exception>
  153. /// <returns></returns>
  154. T Choose();
  155. /// <summary>
  156. /// Create an enumerable, enumerating the items of this collection that satisfies
  157. /// a certain condition.
  158. /// </summary>
  159. /// <param name="filter">The T->bool filter delegate defining the condition</param>
  160. /// <returns>The filtered enumerable</returns>
  161. SCG.IEnumerable<T> Filter(Fun<T, bool> filter);
  162. }
  163. /// <summary>
  164. /// A sized generic collection, that can be enumerated backwards.
  165. /// </summary>
  166. public interface IDirectedCollectionValue<T> : ICollectionValue<T>, IDirectedEnumerable<T>
  167. {
  168. /// <summary>
  169. /// Create a collection containing the same items as this collection, but
  170. /// whose enumerator will enumerate the items backwards. The new collection
  171. /// will become invalid if the original is modified. Method typically used as in
  172. /// <code>foreach (T x in coll.Backwards()) {...}</code>
  173. /// </summary>
  174. /// <returns>The backwards collection.</returns>
  175. new IDirectedCollectionValue<T> Backwards();
  176. /// <summary>
  177. /// Check if there exists an item that satisfies a
  178. /// specific predicate in this collection and return the first one in enumeration order.
  179. /// </summary>
  180. /// <param name="predicate">A delegate
  181. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  182. /// <param name="item"></param>
  183. /// <returns>True is such an item exists</returns>
  184. bool FindLast(Fun<T, bool> predicate, out T item);
  185. }
  186. /// <summary>
  187. /// A generic collection to which one may add items. This is just the intersection
  188. /// of the main stream generic collection interfaces and the priority queue interface,
  189. /// <see cref="T:C5.ICollection`1"/> and <see cref="T:C5.IPriorityQueue`1"/>.
  190. /// </summary>
  191. public interface IExtensible<T> : ICollectionValue<T>, ICloneable
  192. {
  193. /// <summary>
  194. /// If true any call of an updating operation will throw an
  195. /// <code>ReadOnlyCollectionException</code>
  196. /// </summary>
  197. /// <value>True if this collection is read-only.</value>
  198. bool IsReadOnly { get;}
  199. //TODO: wonder where the right position of this is
  200. /// <summary>
  201. ///
  202. /// </summary>
  203. /// <value>False if this collection has set semantics, true if bag semantics.</value>
  204. bool AllowsDuplicates { get;}
  205. //TODO: wonder where the right position of this is. And the semantics.
  206. /// <summary>
  207. /// (Here should be a discussion of the role of equalityComparers. Any ).
  208. /// </summary>
  209. /// <value>The equalityComparer used by this collection to check equality of items.
  210. /// Or null (????) if collection does not check equality at all or uses a comparer.</value>
  211. SCG.IEqualityComparer<T> EqualityComparer { get;}
  212. //ItemEqualityTypeEnum ItemEqualityType {get ;}
  213. //TODO: find a good name
  214. /// <summary>
  215. /// By convention this is true for any collection with set semantics.
  216. /// </summary>
  217. /// <value>True if only one representative of a group of equal items
  218. /// is kept in the collection together with the total count.</value>
  219. bool DuplicatesByCounting { get;}
  220. /// <summary>
  221. /// Add an item to this collection if possible. If this collection has set
  222. /// semantics, the item will be added if not already in the collection. If
  223. /// bag semantics, the item will always be added.
  224. /// </summary>
  225. /// <param name="item">The item to add.</param>
  226. /// <returns>True if item was added.</returns>
  227. bool Add(T item);
  228. /// <summary>
  229. /// Add the elements from another collection with a more specialized item type
  230. /// to this collection. If this
  231. /// collection has set semantics, only items not already in the collection
  232. /// will be added.
  233. /// </summary>
  234. /// <typeparam name="U">The type of items to add</typeparam>
  235. /// <param name="items">The items to add</param>
  236. void AddAll<U>(SCG.IEnumerable<U> items) where U : T;
  237. //void Clear(); // for priority queue
  238. //int Count why not?
  239. /// <summary>
  240. /// Check the integrity of the internal data structures of this collection.
  241. /// <i>This is only relevant for developers of the library</i>
  242. /// </summary>
  243. /// <returns>True if check was passed.</returns>
  244. bool Check();
  245. }
  246. /// <summary>
  247. /// The simplest interface of a main stream generic collection
  248. /// with lookup, insertion and removal operations.
  249. /// </summary>
  250. public interface ICollection<T> : IExtensible<T>, SCG.ICollection<T>
  251. {
  252. //This is somewhat similar to the RandomAccess marker itf in java
  253. /// <summary>
  254. /// The value is symbolic indicating the type of asymptotic complexity
  255. /// in terms of the size of this collection (worst-case or amortized as
  256. /// relevant).
  257. /// <para>See <see cref="T:C5.Speed"/> for the set of symbols.</para>
  258. /// </summary>
  259. /// <value>A characterization of the speed of lookup operations
  260. /// (<code>Contains()</code> etc.) of the implementation of this collection.</value>
  261. Speed ContainsSpeed { get;}
  262. /// <summary>
  263. /// </summary>
  264. /// <value>The number of items in this collection</value>
  265. new int Count { get; }
  266. /// <summary>
  267. /// If true any call of an updating operation will throw an
  268. /// <code>ReadOnlyCollectionException</code>
  269. /// </summary>
  270. /// <value>True if this collection is read-only.</value>
  271. new bool IsReadOnly { get; }
  272. /// <summary>
  273. /// Add an item to this collection if possible. If this collection has set
  274. /// semantics, the item will be added if not already in the collection. If
  275. /// bag semantics, the item will always be added.
  276. /// </summary>
  277. /// <param name="item">The item to add.</param>
  278. /// <returns>True if item was added.</returns>
  279. new bool Add(T item);
  280. /// <summary>
  281. /// Copy the items of this collection to a contiguous part of an array.
  282. /// </summary>
  283. /// <param name="array">The array to copy to</param>
  284. /// <param name="index">The index at which to copy the first item</param>
  285. new void CopyTo(T[] array, int index);
  286. /// <summary>
  287. /// The unordered collection hashcode is defined as the sum of
  288. /// <code>h(hashcode(item))</code> over the items
  289. /// of the collection, where the function <code>h</code> is a function from
  290. /// int to int of the form <code> t -> (a0*t+b0)^(a1*t+b1)^(a2*t+b2)</code>, where
  291. /// the ax and bx are the same for all collection classes.
  292. /// <para>The current implementation uses fixed values for the ax and bx,
  293. /// specified as constants in the code.</para>
  294. /// </summary>
  295. /// <returns>The unordered hashcode of this collection.</returns>
  296. int GetUnsequencedHashCode();
  297. /// <summary>
  298. /// Compare the contents of this collection to another one without regards to
  299. /// the sequence order. The comparison will use this collection's itemequalityComparer
  300. /// to compare individual items.
  301. /// </summary>
  302. /// <param name="otherCollection">The collection to compare to.</param>
  303. /// <returns>True if this collection and that contains the same items.</returns>
  304. bool UnsequencedEquals(ICollection<T> otherCollection);
  305. /// <summary>
  306. /// Check if this collection contains (an item equivalent to according to the
  307. /// itemequalityComparer) a particular value.
  308. /// </summary>
  309. /// <param name="item">The value to check for.</param>
  310. /// <returns>True if the items is in this collection.</returns>
  311. new bool Contains(T item);
  312. /// <summary>
  313. /// Count the number of items of the collection equal to a particular value.
  314. /// Returns 0 if and only if the value is not in the collection.
  315. /// </summary>
  316. /// <param name="item">The value to count.</param>
  317. /// <returns>The number of copies found.</returns>
  318. int ContainsCount(T item);
  319. /// <summary>
  320. ///
  321. /// </summary>
  322. /// <returns></returns>
  323. ICollectionValue<T> UniqueItems();
  324. /// <summary>
  325. ///
  326. /// </summary>
  327. /// <returns></returns>
  328. ICollectionValue<KeyValuePair<T, int>> ItemMultiplicities();
  329. /// <summary>
  330. /// Check whether this collection contains all the values in another collection.
  331. /// If this collection has bag semantics (<code>AllowsDuplicates==true</code>)
  332. /// the check is made with respect to multiplicities, else multiplicities
  333. /// are not taken into account.
  334. /// </summary>
  335. /// <param name="items">The </param>
  336. /// <typeparam name="U"></typeparam>
  337. /// <returns>True if all values in <code>items</code>is in this collection.</returns>
  338. bool ContainsAll<U>(SCG.IEnumerable<U> items) where U : T;
  339. /// <summary>
  340. /// Check if this collection contains an item equivalent according to the
  341. /// itemequalityComparer to a particular value. If so, return in the ref argument (a
  342. /// binary copy of) the actual value found.
  343. /// </summary>
  344. /// <param name="item">The value to look for.</param>
  345. /// <returns>True if the items is in this collection.</returns>
  346. bool Find(ref T item);
  347. //This should probably just be bool Add(ref T item); !!!
  348. /// <summary>
  349. /// Check if this collection contains an item equivalent according to the
  350. /// itemequalityComparer to a particular value. If so, return in the ref argument (a
  351. /// binary copy of) the actual value found. Else, add the item to the collection.
  352. /// </summary>
  353. /// <param name="item">The value to look for.</param>
  354. /// <returns>True if the item was found (hence not added).</returns>
  355. bool FindOrAdd(ref T item);
  356. /// <summary>
  357. /// Check if this collection contains an item equivalent according to the
  358. /// itemequalityComparer to a particular value. If so, update the item in the collection
  359. /// with a (binary copy of) the supplied value. If the collection has bag semantics,
  360. /// it depends on the value of DuplicatesByCounting if this updates all equivalent copies in
  361. /// the collection or just one.
  362. /// </summary>
  363. /// <param name="item">Value to update.</param>
  364. /// <returns>True if the item was found and hence updated.</returns>
  365. bool Update(T item);
  366. /// <summary>
  367. /// Check if this collection contains an item equivalent according to the
  368. /// itemequalityComparer to a particular value. If so, update the item in the collection
  369. /// with a (binary copy of) the supplied value. If the collection has bag semantics,
  370. /// it depends on the value of DuplicatesByCounting if this updates all equivalent copies in
  371. /// the collection or just one.
  372. /// </summary>
  373. /// <param name="item">Value to update.</param>
  374. /// <param name="olditem">On output the olditem, if found.</param>
  375. /// <returns>True if the item was found and hence updated.</returns>
  376. bool Update(T item, out T olditem);
  377. /// <summary>
  378. /// Check if this collection contains an item equivalent according to the
  379. /// itemequalityComparer to a particular value. If so, update the item in the collection
  380. /// to with a binary copy of the supplied value; else add the value to the collection.
  381. /// </summary>
  382. /// <param name="item">Value to add or update.</param>
  383. /// <returns>True if the item was found and updated (hence not added).</returns>
  384. bool UpdateOrAdd(T item);
  385. /// <summary>
  386. /// Check if this collection contains an item equivalent according to the
  387. /// itemequalityComparer to a particular value. If so, update the item in the collection
  388. /// to with a binary copy of the supplied value; else add the value to the collection.
  389. /// </summary>
  390. /// <param name="item">Value to add or update.</param>
  391. /// <param name="olditem">On output the olditem, if found.</param>
  392. /// <returns>True if the item was found and updated (hence not added).</returns>
  393. bool UpdateOrAdd(T item, out T olditem);
  394. /// <summary>
  395. /// Remove a particular item from this collection. If the collection has bag
  396. /// semantics only one copy equivalent to the supplied item is removed.
  397. /// </summary>
  398. /// <param name="item">The value to remove.</param>
  399. /// <returns>True if the item was found (and removed).</returns>
  400. new bool Remove(T item);
  401. /// <summary>
  402. /// Remove a particular item from this collection if found. If the collection
  403. /// has bag semantics only one copy equivalent to the supplied item is removed,
  404. /// which one is implementation dependent.
  405. /// If an item was removed, report a binary copy of the actual item removed in
  406. /// the argument.
  407. /// </summary>
  408. /// <param name="item">The value to remove.</param>
  409. /// <param name="removeditem">The value removed if any.</param>
  410. /// <returns>True if the item was found (and removed).</returns>
  411. bool Remove(T item, out T removeditem);
  412. /// <summary>
  413. /// Remove all items equivalent to a given value.
  414. /// </summary>
  415. /// <param name="item">The value to remove.</param>
  416. void RemoveAllCopies(T item);
  417. /// <summary>
  418. /// Remove all items in another collection from this one. If this collection
  419. /// has bag semantics, take multiplicities into account.
  420. /// </summary>
  421. /// <typeparam name="U"></typeparam>
  422. /// <param name="items">The items to remove.</param>
  423. void RemoveAll<U>(SCG.IEnumerable<U> items) where U : T;
  424. //void RemoveAll(Fun<T, bool> predicate);
  425. /// <summary>
  426. /// Remove all items from this collection.
  427. /// </summary>
  428. new void Clear();
  429. /// <summary>
  430. /// Remove all items not in some other collection from this one. If this collection
  431. /// has bag semantics, take multiplicities into account.
  432. /// </summary>
  433. /// <typeparam name="U"></typeparam>
  434. /// <param name="items">The items to retain.</param>
  435. void RetainAll<U>(SCG.IEnumerable<U> items) where U : T;
  436. //void RetainAll(Fun<T, bool> predicate);
  437. //IDictionary<T> UniqueItems()
  438. }
  439. /// <summary>
  440. /// An editable collection maintaining a definite sequence order of the items.
  441. ///
  442. /// <i>Implementations of this interface must compute the hash code and
  443. /// equality exactly as prescribed in the method definitions in order to
  444. /// be consistent with other collection classes implementing this interface.</i>
  445. /// <i>This interface is usually implemented by explicit interface implementation,
  446. /// not as ordinary virtual methods.</i>
  447. /// </summary>
  448. public interface ISequenced<T> : ICollection<T>, IDirectedCollectionValue<T>
  449. {
  450. /// <summary>
  451. /// The hashcode is defined as <code>h(...h(h(h(x1),x2),x3),...,xn)</code> for
  452. /// <code>h(a,b)=CONSTANT*a+b</code> and the x's the hash codes of the items of
  453. /// this collection.
  454. /// </summary>
  455. /// <returns>The sequence order hashcode of this collection.</returns>
  456. int GetSequencedHashCode();
  457. /// <summary>
  458. /// Compare this sequenced collection to another one in sequence order.
  459. /// </summary>
  460. /// <param name="otherCollection">The sequenced collection to compare to.</param>
  461. /// <returns>True if this collection and that contains equal (according to
  462. /// this collection's itemequalityComparer) in the same sequence order.</returns>
  463. bool SequencedEquals(ISequenced<T> otherCollection);
  464. }
  465. /// <summary>
  466. /// A sequenced collection, where indices of items in the order are maintained
  467. /// </summary>
  468. public interface IIndexed<T> : ISequenced<T>
  469. {
  470. /// <summary>
  471. /// </summary>
  472. /// <exception cref="IndexOutOfRangeException"> if <code>index</code> is negative or
  473. /// &gt;= the size of the collection.</exception>
  474. /// <value>The <code>index</code>'th item of this list.</value>
  475. /// <param name="index">the index to lookup</param>
  476. T this[int index] { get;}
  477. /// <summary>
  478. ///
  479. /// </summary>
  480. /// <value></value>
  481. Speed IndexingSpeed { get;}
  482. /// <summary>
  483. /// </summary>
  484. /// <exception cref="ArgumentOutOfRangeException"></exception>
  485. /// <value>The directed collection of items in a specific index interval.</value>
  486. /// <param name="start">The low index of the interval (inclusive).</param>
  487. /// <param name="count">The size of the range.</param>
  488. IDirectedCollectionValue<T> this[int start, int count] { get;}
  489. /// <summary>
  490. /// Searches for an item in the list going forwards from the start.
  491. /// </summary>
  492. /// <param name="item">Item to search for.</param>
  493. /// <returns>Index of item from start. A negative number if item not found,
  494. /// namely the one's complement of the index at which the Add operation would put the item.</returns>
  495. int IndexOf(T item);
  496. /// <summary>
  497. /// Searches for an item in the list going backwards from the end.
  498. /// </summary>
  499. /// <param name="item">Item to search for.</param>
  500. /// <returns>Index of of item from the end. A negative number if item not found,
  501. /// namely the two-complement of the index at which the Add operation would put the item.</returns>
  502. int LastIndexOf(T item);
  503. /// <summary>
  504. /// Check if there exists an item that satisfies a
  505. /// specific predicate in this collection and return the index of the first one.
  506. /// </summary>
  507. /// <param name="predicate">A delegate
  508. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  509. /// <returns>the index, if found, a negative value else</returns>
  510. int FindIndex(Fun<T, bool> predicate);
  511. /// <summary>
  512. /// Check if there exists an item that satisfies a
  513. /// specific predicate in this collection and return the index of the last one.
  514. /// </summary>
  515. /// <param name="predicate">A delegate
  516. /// (<see cref="T:C5.Fun`2"/> with <code>R == bool</code>) defining the predicate</param>
  517. /// <returns>the index, if found, a negative value else</returns>
  518. int FindLastIndex(Fun<T, bool> predicate);
  519. /// <summary>
  520. /// Remove the item at a specific position of the list.
  521. /// </summary>
  522. /// <exception cref="IndexOutOfRangeException"> if <code>index</code> is negative or
  523. /// &gt;= the size of the collection.</exception>
  524. /// <param name="index">The index of the item to remove.</param>
  525. /// <returns>The removed item.</returns>
  526. T RemoveAt(int index);
  527. /// <summary>
  528. /// Remove all items in an index interval.
  529. /// </summary>
  530. /// <exception cref="ArgumentOutOfRangeException"> if start or count
  531. /// is negative or start+count &gt; the size of the collection.</exception>
  532. /// <param name="start">The index of the first item to remove.</param>
  533. /// <param name="count">The number of items to remove.</param>
  534. void RemoveInterval(int start, int count);
  535. }
  536. //TODO: decide if this should extend ICollection
  537. /// <summary>
  538. /// The interface describing the operations of a LIFO stack data structure.
  539. /// </summary>
  540. /// <typeparam name="T">The item type</typeparam>
  541. public interface IStack<T> : IDirectedCollectionValue<T>
  542. {
  543. /// <summary>
  544. ///
  545. /// </summary>
  546. /// <value></value>
  547. bool AllowsDuplicates { get;}
  548. /// <summary>
  549. /// Get the <code>index</code>'th element of the stack. The bottom of the stack has index 0.
  550. /// </summary>
  551. /// <param name="index"></param>
  552. /// <returns></returns>
  553. T this[int index] { get;}
  554. /// <summary>
  555. /// Push an item to the top of the stack.
  556. /// </summary>
  557. /// <param name="item">The item</param>
  558. void Push(T item);
  559. /// <summary>
  560. /// Pop the item at the top of the stack from the stack.
  561. /// </summary>
  562. /// <returns>The popped item.</returns>
  563. T Pop();
  564. }
  565. /// <summary>
  566. /// The interface describing the operations of a FIFO queue data structure.
  567. /// </summary>
  568. /// <typeparam name="T">The item type</typeparam>
  569. public interface IQueue<T> : IDirectedCollectionValue<T>
  570. {
  571. /// <summary>
  572. ///
  573. /// </summary>
  574. /// <value></value>
  575. bool AllowsDuplicates { get;}
  576. /// <summary>
  577. /// Get the <code>index</code>'th element of the queue. The front of the queue has index 0.
  578. /// </summary>
  579. /// <param name="index"></param>
  580. /// <returns></returns>
  581. T this[int index] { get;}
  582. /// <summary>
  583. /// Enqueue an item at the back of the queue.
  584. /// </summary>
  585. /// <param name="item">The item</param>
  586. void Enqueue(T item);
  587. /// <summary>
  588. /// Dequeue an item from the front of the queue.
  589. /// </summary>
  590. /// <returns>The item</returns>
  591. T Dequeue();
  592. }
  593. /// <summary>
  594. /// This is an indexed collection, where the item order is chosen by
  595. /// the user at insertion time.
  596. ///
  597. /// NBNBNB: we need a description of the view functionality here!
  598. /// </summary>
  599. public interface IList<T> : IIndexed<T>, IDisposable, SCG.IList<T>, System.Collections.IList
  600. {
  601. /// <summary>
  602. /// </summary>
  603. /// <exception cref="NoSuchItemException"> if this list is empty.</exception>
  604. /// <value>The first item in this list.</value>
  605. T First { get;}
  606. /// <summary>
  607. /// </summary>
  608. /// <exception cref="NoSuchItemException"> if this list is empty.</exception>
  609. /// <value>The last item in this list.</value>
  610. T Last { get;}
  611. /// <summary>
  612. /// Since <code>Add(T item)</code> always add at the end of the list,
  613. /// this describes if list has FIFO or LIFO semantics.
  614. /// </summary>
  615. /// <value>True if the <code>Remove()</code> operation removes from the
  616. /// start of the list, false if it removes from the end.</value>
  617. bool FIFO { get; set;}
  618. /// <summary>
  619. ///
  620. /// </summary>
  621. bool IsFixedSize { get; }
  622. /// <summary>
  623. /// On this list, this indexer is read/write.
  624. /// </summary>
  625. /// <exception cref="IndexOutOfRangeException"> if index is negative or
  626. /// &gt;= the size of the collection.</exception>
  627. /// <value>The index'th item of this list.</value>
  628. /// <param name="index">The index of the item to fetch or store.</param>
  629. new T this[int index] { get; set;}
  630. #region Ambiguous calls when extending SCG.IList<T>
  631. #region SCG.ICollection<T>
  632. /// <summary>
  633. ///
  634. /// </summary>
  635. new int Count { get; }
  636. /// <summary>
  637. ///
  638. /// </summary>
  639. new bool IsReadOnly { get; }
  640. /// <summary>
  641. ///
  642. /// </summary>
  643. /// <param name="item"></param>
  644. /// <returns></returns>
  645. new bool Add(T item);
  646. /// <summary>
  647. ///
  648. /// </summary>
  649. new void Clear();
  650. /// <summary>
  651. ///
  652. /// </summary>
  653. /// <param name="item"></param>
  654. /// <returns></returns>
  655. new bool Contains(T item);
  656. /// <summary>
  657. ///
  658. /// </summary>
  659. /// <param name="array"></param>
  660. /// <param name="index"></param>
  661. new void CopyTo(T[] array, int index);
  662. /// <summary>
  663. ///
  664. /// </summary>
  665. /// <param name="item"></param>
  666. /// <returns></returns>
  667. new bool Remove(T item);
  668. #endregion
  669. #region SCG.IList<T> proper
  670. /// <summary>
  671. /// Searches for an item in the list going forwards from the start.
  672. /// </summary>
  673. /// <param name="item">Item to search for.</param>
  674. /// <returns>Index of item from start. A negative number if item not found,
  675. /// namely the one's complement of the index at which the Add operation would put the item.</returns>
  676. new int IndexOf(T item);
  677. /// <summary>
  678. /// Remove the item at a specific position of the list.
  679. /// </summary>
  680. /// <exception cref="IndexOutOfRangeException"> if <code>index</code> is negative or
  681. /// &gt;= the size of the collection.</exception>
  682. /// <param name="index">The index of the item to remove.</param>
  683. /// <returns>The removed item.</returns>
  684. new T RemoveAt(int index);
  685. #endregion
  686. #endregion
  687. /*/// <summary>
  688. /// Insert an item at a specific index location in this list.
  689. /// </summary>
  690. /// <exception cref="IndexOutOfRangeException"> if <code>index</code> is negative or
  691. /// &gt; the size of the collection.</exception>
  692. /// <exception cref="DuplicateNotAllowedException"> if the list has
  693. /// <code>AllowsDuplicates==false</code> and the item is
  694. /// already in the list.</exception>
  695. /// <param name="index">The index at which to insert.</param>
  696. /// <param name="item">The item to insert.</param>
  697. void Insert(int index, T item);*/
  698. /// <summary>
  699. /// Insert an item at the end of a compatible view, used as a pointer.
  700. /// <para>The <code>pointer</code> must be a view on the same list as
  701. /// <code>this</code> and the endpoitn of <code>pointer</code> must be
  702. /// a valid insertion point of <code>this</code></para>
  703. /// </summary>
  704. /// <exception cref="IncompatibleViewException">If <code>pointer</code>
  705. /// is not a view on the same list as <code>this</code></exception>
  706. /// <exception cref="IndexOutOfRangeException"><b>??????</b> if the endpoint of
  707. /// <code>pointer</code> is not inside <code>this</code></exception>
  708. /// <exception cref="DuplicateNotAllowedException"> if the list has
  709. /// <code>AllowsDuplicates==false</code> and the item is
  710. /// already in the list.</exception>
  711. /// <param name="pointer"></param>
  712. /// <param name="item"></param>
  713. void Insert(IList<T> pointer, T item);
  714. /// <summary>
  715. /// Insert an item at the front of this list.
  716. /// <exception cref="DuplicateNotAllowedException"/> if the list has
  717. /// <code>AllowsDuplicates==false</code> and the item is
  718. /// already in the list.
  719. /// </summary>
  720. /// <param name="item">The item to insert.</param>
  721. void InsertFirst(T item);
  722. /// <summary>
  723. /// Insert an item at the back of this list.
  724. /// <exception cref="DuplicateNotAllowedException"/> if the list has
  725. /// <code>AllowsDuplicates==false</code> and the item is
  726. /// already in the list.
  727. /// </summary>
  728. /// <param name="item">The item to insert.</param>
  729. void InsertLast(T item);
  730. /// <summary>
  731. /// Insert into this list all items from an enumerable collection starting
  732. /// at a particular index.
  733. /// </summary>
  734. /// <exception cref="IndexOutOfRangeException"> if <code>index</code> is negative or
  735. /// &gt; the size of the collection.</exception>
  736. /// <exception cref="DuplicateNotAllowedException"> if the list has
  737. /// <code>AllowsDuplicates==false</code> and one of the items to insert is
  738. /// already in the list.</exception>
  739. /// <param name="index">Index to start inserting at</param>
  740. /// <param name="items">Items to insert</param>
  741. /// <typeparam name="U"></typeparam>
  742. void InsertAll<U>(int index, SCG.IEnumerable<U> items) where U : T;
  743. /// <summary>
  744. /// Create a new list consisting of the items of this list satisfying a
  745. /// certain predicate.
  746. /// </summary>
  747. /// <param name="filter">The filter delegate defining the predicate.</param>
  748. /// <returns>The new list.</returns>
  749. IList<T> FindAll(Fun<T, bool> filter);
  750. /// <summary>
  751. /// Create a new list consisting of the results of mapping all items of this
  752. /// list. The new list will use the default equalityComparer for the item type V.
  753. /// </summary>
  754. /// <typeparam name="V">The type of items of the new list</typeparam>
  755. /// <param name="mapper">The delegate defining the map.</param>
  756. /// <returns>The new list.</returns>
  757. IList<V> Map<V>(Fun<T, V> mapper);
  758. /// <summary>
  759. /// Create a new list consisting of the results of mapping all items of this
  760. /// list. The new list will use a specified equalityComparer for the item type.
  761. /// </summary>
  762. /// <typeparam name="V">The type of items of the new list</typeparam>
  763. /// <param name="mapper">The delegate defining the map.</param>
  764. /// <param name="equalityComparer">The equalityComparer to use for the new list</param>
  765. /// <returns>The new list.</returns>
  766. IList<V> Map<V>(Fun<T, V> mapper, SCG.IEqualityComparer<V> equalityComparer);
  767. /// <summary>
  768. /// Remove one item from the list: from the front if <code>FIFO</code>
  769. /// is true, else from the back.
  770. /// <exception cref="NoSuchItemException"/> if this list is empty.
  771. /// </summary>
  772. /// <returns>The removed item.</returns>
  773. T Remove();
  774. /// <summary>
  775. /// Remove one item from the front of the list.
  776. /// <exception cref="NoSuchItemException"/> if this list is empty.
  777. /// </summary>
  778. /// <returns>The removed item.</returns>
  779. T RemoveFirst();
  780. /// <summary>
  781. /// Remove one item from the back of the list.
  782. /// <exception cref="NoSuchItemException"/> if this list is empty.
  783. /// </summary>
  784. /// <returns>The removed item.</returns>
  785. T RemoveLast();
  786. /// <summary>
  787. /// Create a list view on this list.
  788. /// <exception cref="ArgumentOutOfRangeException"/> if the view would not fit into
  789. /// this list.
  790. /// </summary>
  791. /// <param name="start">The index in this list of the start of the view.</param>
  792. /// <param name="count">The size of the view.</param>
  793. /// <returns>The new list view.</returns>
  794. IList<T> View(int start, int count);
  795. /// <summary>
  796. /// Create a list view on this list containing the (first) occurrence of a particular item.
  797. /// <exception cref="NoSuchItemException"/> if the item is not in this list.
  798. /// </summary>
  799. /// <param name="item">The item to find.</param>
  800. /// <returns>The new list view.</returns>
  801. IList<T> ViewOf(T item);
  802. /// <summary>
  803. /// Create a list view on this list containing the last occurrence of a particular item.
  804. /// <exception cref="NoSuchItemException"/> if the item is not in this list.
  805. /// </summary>
  806. /// <param name="item">The item to find.</param>
  807. /// <returns>The new list view.</returns>
  808. IList<T> LastViewOf(T item);
  809. /// <summary>
  810. /// Null if this list is not a view.
  811. /// </summary>
  812. /// <value>Underlying list for view.</value>
  813. IList<T> Underlying { get;}
  814. /// <summary>
  815. /// </summary>
  816. /// <value>Offset for this list view or 0 for an underlying list.</value>
  817. int Offset { get;}
  818. /// <summary>
  819. ///
  820. /// </summary>
  821. /// <value></value>
  822. bool IsValid { get;}
  823. /// <summary>
  824. /// Slide this list view along the underlying list.
  825. /// </summary>
  826. /// <exception cref="NotAViewException"> if this list is not a view.</exception>
  827. /// <exception cref="ArgumentOutOfRangeException"> if the operation
  828. /// would bring either end of the view outside the underlying list.</exception>
  829. /// <param name="offset">The signed amount to slide: positive to slide
  830. /// towards the end.</param>
  831. IList<T> Slide(int offset);
  832. /// <summary>
  833. /// Slide this list view along the underlying list, changing its size.
  834. ///
  835. /// </summary>
  836. /// <exception cref="NotAViewException"> if this list is not a view.</exception>
  837. /// <exception cref="ArgumentOutOfRangeException"> if the operation
  838. /// would bring either end of the view outside the underlying list.</exception>
  839. /// <param name="offset">The signed amount to slide: positive to slide
  840. /// towards the end.</param>
  841. /// <param name="size">The new size of the view.</param>
  842. IList<T> Slide(int offset, int size);
  843. /// <summary>
  844. ///
  845. /// </summary>
  846. /// <param name="offset"></param>
  847. /// <returns></returns>
  848. bool TrySlide(int offset);
  849. /// <summary>
  850. ///
  851. /// </summary>
  852. /// <param name="offset"></param>
  853. /// <param name="size"></param>
  854. /// <returns></returns>
  855. bool TrySlide(int offset, int size);
  856. /// <summary>
  857. ///
  858. /// <para>Returns null if <code>otherView</code> is strictly to the left of this view</para>
  859. /// </summary>
  860. /// <param name="otherView"></param>
  861. /// <exception cref="IncompatibleViewException">If otherView does not have the same underlying list as this</exception>
  862. /// <exception cref="ArgumentOutOfRangeException">If <code>otherView</code> is strictly to the left of this view</exception>
  863. /// <returns></returns>
  864. IList<T> Span(IList<T> otherView);
  865. /// <summary>
  866. /// Reverse the list so the items are in the opposite sequence order.
  867. /// </summary>
  868. void Reverse();
  869. /// <summary>
  870. /// Check if this list is sorted according to the default sorting order
  871. /// for the item type T, as defined by the <see cref="T:C5.Comparer`1"/> class
  872. /// </summary>
  873. /// <exception cref="NotComparableException">if T is not comparable</exception>
  874. /// <returns>True if the list is sorted, else false.</returns>
  875. bool IsSorted();
  876. /// <summary>
  877. /// Check if this list is sorted according to a specific sorting order.
  878. /// </summary>
  879. /// <param name="comparer">The comparer defining the sorting order.</param>
  880. /// <returns>True if the list is sorted, else false.</returns>
  881. bool IsSorted(SCG.IComparer<T> comparer);
  882. /// <summary>
  883. /// Sort the items of the list according to the default sorting order
  884. /// for the item type T, as defined by the <see cref="T:C5.Comparer`1"/> class
  885. /// </summary>
  886. /// <exception cref="NotComparableException">if T is not comparable</exception>
  887. void Sort();
  888. /// <summary>
  889. /// Sort the items of the list according to a specified sorting order.
  890. /// <para>The sorting does not perform duplicate elimination or identify items
  891. /// according to the comparer or itemequalityComparer. I.e. the list as an
  892. /// unsequenced collection with binary equality, will not change.
  893. /// </para>
  894. /// </summary>
  895. /// <param name="comparer">The comparer defining the sorting order.</param>
  896. void Sort(SCG.IComparer<T> comparer);
  897. /// <summary>
  898. /// Randomly shuffle the items of this list.
  899. /// </summary>
  900. void Shuffle();
  901. /// <summary>
  902. /// Shuffle the items of this list according to a specific random source.
  903. /// </summary>
  904. /// <param name="rnd">The random source.</param>
  905. void Shuffle(Random rnd);
  906. }
  907. /// <summary>
  908. /// The base type of a priority queue handle
  909. /// </summary>
  910. /// <typeparam name="T"></typeparam>
  911. public interface IPriorityQueueHandle<T>
  912. {
  913. //TODO: make abstract and prepare for double dispatch:
  914. //public virtual bool Delete(IPriorityQueue<T> q) { throw new InvalidFooException();}
  915. //bool Replace(T item);
  916. }
  917. /// <summary>
  918. /// A generic collection of items prioritized by a comparison (order) relation.
  919. /// Supports adding items and reporting or removing extremal elements.
  920. /// <para>
  921. ///
  922. /// </para>
  923. /// When adding an item, the user may choose to have a handle allocated for this item in the queue.
  924. /// The resulting handle may be used for deleting the item even if not extremal, and for replacing the item.
  925. /// A priority queue typically only holds numeric priorities associated with some objects
  926. /// maintained separately in other collection objects.
  927. /// </summary>
  928. public interface IPriorityQueue<T> : IExtensible<T>
  929. {
  930. /// <summary>
  931. /// Find the current least item of this priority queue.
  932. /// </summary>
  933. /// <returns>The least item.</returns>
  934. T FindMin();
  935. /// <summary>
  936. /// Remove the least item from this priority queue.
  937. /// </summary>
  938. /// <returns>The removed item.</returns>
  939. T DeleteMin();
  940. /// <summary>
  941. /// Find the current largest item of this priority queue.
  942. /// </summary>
  943. /// <returns>The largest item.</returns>
  944. T FindMax();
  945. /// <summary>
  946. /// Remove the largest item from this priority queue.
  947. /// </summary>
  948. /// <returns>The removed item.</returns>
  949. T DeleteMax();
  950. /// <summary>
  951. /// The comparer object supplied at creation time for this collection
  952. /// </summary>
  953. /// <value>The comparer</value>
  954. SCG.IComparer<T> Comparer { get;}
  955. /// <summary>
  956. /// Get or set the item corresponding to a handle. Throws exceptions on
  957. /// invalid handles.
  958. /// </summary>
  959. /// <param name="handle"></param>
  960. /// <returns></returns>
  961. T this[IPriorityQueueHandle<T> handle] { get; set;}
  962. /// <summary>
  963. /// Check if the entry corresponding to a handle is in the priority queue.
  964. /// </summary>
  965. /// <param name="handle"></param>
  966. /// <param name="item"></param>
  967. /// <returns></returns>
  968. bool Find(IPriorityQueueHandle<T> handle, out T item);
  969. /// <summary>
  970. /// Add an item to the priority queue, receiving a
  971. /// handle for the item in the queue,
  972. /// or reusing an existing unused handle.
  973. /// </summary>
  974. /// <param name="handle">On output: a handle for the added item.
  975. /// On input: null for allocating a new handle, or a currently unused handle for reuse.
  976. /// A handle for reuse must be compatible with this priority queue,
  977. /// by being created by a priority queue of the same runtime type, but not
  978. /// necessarily the same priority queue object.</param>
  979. /// <param name="item"></param>
  980. /// <returns></returns>
  981. bool Add(ref IPriorityQueueHandle<T> handle, T item);
  982. /// <summary>
  983. /// Delete an item with a handle from a priority queue
  984. /// </summary>
  985. /// <param name="handle">The handle for the item. The handle will be invalidated, but reusable.</param>
  986. /// <returns>The deleted item</returns>
  987. T Delete(IPriorityQueueHandle<T> handle);
  988. /// <summary>
  989. /// Replace an item with a handle in a priority queue with a new item.
  990. /// Typically used for changing the priority of some queued object.
  991. /// </summary>
  992. /// <param name="handle">The handle for the old item</param>
  993. /// <param name="item">The new item</param>
  994. /// <returns>The old item</returns>
  995. T Replace(IPriorityQueueHandle<T> handle, T item);
  996. /// <summary>
  997. /// Find the current least item of this priority queue.
  998. /// </summary>
  999. /// <param name="handle">On return: the handle of the item.</param>
  1000. /// <returns>The least item.</returns>
  1001. T FindMin(out IPriorityQueueHandle<T> handle);
  1002. /// <summary>
  1003. /// Find the current largest item of this priority queue.
  1004. /// </summary>
  1005. /// <param name="handle">On return: the handle of the item.</param>
  1006. /// <returns>The largest item.</returns>
  1007. T FindMax(out IPriorityQueueHandle<T> handle);
  1008. /// <summary>
  1009. /// Remove the least item from this priority queue.
  1010. /// </summary>
  1011. /// <param name="handle">On return: the handle of the removed item.</param>
  1012. /// <returns>The removed item.</returns>
  1013. T DeleteMin(out IPriorityQueueHandle<T> handle);
  1014. /// <summary>
  1015. /// Remove the largest item from this priority queue.
  1016. /// </summary>
  1017. /// <param name="handle">On return: the handle of the removed item.</param>
  1018. /// <returns>The removed item.</returns>
  1019. T DeleteMax(out IPriorityQueueHandle<T> handle);
  1020. }
  1021. /// <summary>
  1022. /// A sorted collection, i.e. a collection where items are maintained and can be searched for in sorted order.
  1023. /// Thus the sequence order is given as a sorting order.
  1024. ///
  1025. /// <para>The sorting order is defined by a comparer, an object of type IComparer&lt;T&gt;
  1026. /// (<see cref="T:C5.IComparer`1"/>). Implementors of this interface will normally let the user
  1027. /// define the comparer as an argument to a constructor.
  1028. /// Usually there will also be constructors without a comparer argument, in which case the
  1029. /// comparer should be the defalt comparer for the item type, <see cref="P:C5.Comparer`1.Default"/>.</para>
  1030. ///
  1031. /// <para>The comparer of the sorted collection is available as the <code>Comparer</code> property
  1032. /// (<see cref="P:C5.ISorted`1.Comparer"/>).</para>
  1033. ///
  1034. /// <para>The methods are grouped according to
  1035. /// <list>
  1036. /// <item>Extrema: report or report and delete an extremal item. This is reminiscent of simplified priority queues.</item>
  1037. /// <item>Nearest neighbor: report predecessor or successor in the collection of an item. Cut belongs to this group.</item>
  1038. /// <item>Range: report a view of a range of elements or remove all elements in a range.</item>
  1039. /// <item>AddSorted: add a collection of items known to be sorted in the same order (should be faster) (to be removed?)</item>
  1040. /// </list>
  1041. /// </para>
  1042. ///
  1043. /// <para>Since this interface extends ISequenced&lt;T&gt;, sorted collections will also have an
  1044. /// item equalityComparer (<see cref="P:C5.IExtensible`1.EqualityComparer"/>). This equalityComparer will not be used in connection with
  1045. /// the inner workings of the sorted collection, but will be used if the sorted collection is used as
  1046. /// an item in a collection of unsequenced or sequenced collections,
  1047. /// (<see cref="T:C5.ICollection`1"/> and <see cref="T:C5.ISequenced`1"/>)</para>
  1048. ///
  1049. /// <para>Note that code may check if two sorted collections has the same sorting order
  1050. /// by checking if the Comparer properties are equal. This is done a few places in this library
  1051. /// for optimization purposes.</para>
  1052. /// </summary>
  1053. public interface ISorted<T> : ISequenced<T>
  1054. {
  1055. /// <summary>
  1056. /// Find the current least item of this sorted collection.
  1057. /// </summary>
  1058. /// <exception cref="NoSuchItemException"> if the collection is empty.</exception>
  1059. /// <returns>The least item.</returns>
  1060. T FindMin();
  1061. /// <summary>
  1062. /// Remove the least item from this sorted collection.
  1063. /// </summary>
  1064. /// <exception cref="NoSuchItemException"> if the collection is empty.</exception>
  1065. /// <returns>The removed item.</returns>
  1066. T DeleteMin();
  1067. /// <summary>
  1068. /// Find the current largest item of this sorted collection.
  1069. /// </summary>
  1070. /// <exception cref="NoSuchItemException"> if the collection is empty.</exception>
  1071. /// <returns>The largest item.</returns>
  1072. T FindMax();
  1073. /// <summary>
  1074. /// Remove the largest item from this sorted collection.
  1075. /// </summary>
  1076. /// <exception cref="NoSuchItemException"> if the collection is empty.</exception>
  1077. /// <returns>The removed item.</returns>
  1078. T DeleteMax();
  1079. /// <summary>
  1080. /// The comparer object supplied at creation time for this sorted collection.
  1081. /// </summary>
  1082. /// <value>The comparer</value>
  1083. SCG.IComparer<T> Comparer { get; }
  1084. /// <summary>
  1085. /// Find the strict predecessor of item in the sorted collection,
  1086. /// that is, the greatest item in the collection smaller than the item.
  1087. /// </summary>
  1088. /// <param name="item">The item to find the predecessor for.</param>
  1089. /// <param name="res">The predecessor, if any; otherwise the default value for T.</param>
  1090. /// <returns>True if item has a predecessor; otherwise false.</returns>
  1091. bool TryPredecessor(T item, out T res);
  1092. /// <summary>
  1093. /// Find the strict successor of item in the sorted collection,
  1094. /// that is, the least item in the collection greater than the supplied value.
  1095. /// </summary>
  1096. /// <param name="item">The item to find the successor for.</param>
  1097. /// <param name="res">The successor, if any; otherwise the default value for T.</param>
  1098. /// <returns>True …

Large files files are truncated, but you can click here to view the full file