Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. ** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
  3. ** Copyright (C) 2011 Silicon Graphics, Inc.
  4. ** All Rights Reserved.
  5. **
  6. ** Permission is hereby granted, free of charge, to any person obtaining a copy
  7. ** of this software and associated documentation files (the "Software"), to deal
  8. ** in the Software without restriction, including without limitation the rights
  9. ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  10. ** of the Software, and to permit persons to whom the Software is furnished to do so,
  11. ** subject to the following conditions:
  12. **
  13. ** The above copyright notice including the dates of first publication and either this
  14. ** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be
  15. ** included in all copies or substantial portions of the Software.
  16. **
  17. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  18. ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  19. ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC.
  20. ** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  22. ** OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not
  25. ** be used in advertising or otherwise to promote the sale, use or other dealings in
  26. ** this Software without prior written authorization from Silicon Graphics, Inc.
  27. */
  28. /*
  29. ** Original Author: Eric Veach, July 1994.
  30. ** libtess2: Mikko Mononen, http://code.google.com/p/libtess2/.
  31. ** LibTessDotNet: Remi Gillig, https://github.com/speps/LibTessDotNet
  32. */
  33. namespace Unity.SpriteShape.External
  34. {
  35. namespace LibTessDotNet
  36. {
  37. internal class Dict<TValue> where TValue : class
  38. {
  39. public class Node
  40. {
  41. internal TValue _key;
  42. internal Node _prev, _next;
  43. public TValue Key { get { return _key; } }
  44. public Node Prev { get { return _prev; } }
  45. public Node Next { get { return _next; } }
  46. }
  47. public delegate bool LessOrEqual(TValue lhs, TValue rhs);
  48. private LessOrEqual _leq;
  49. Node _head;
  50. public Dict(LessOrEqual leq)
  51. {
  52. _leq = leq;
  53. _head = new Node { _key = null };
  54. _head._prev = _head;
  55. _head._next = _head;
  56. }
  57. public Node Insert(TValue key)
  58. {
  59. return InsertBefore(_head, key);
  60. }
  61. public Node InsertBefore(Node node, TValue key)
  62. {
  63. do {
  64. node = node._prev;
  65. } while (node._key != null && !_leq(node._key, key));
  66. var newNode = new Node { _key = key };
  67. newNode._next = node._next;
  68. node._next._prev = newNode;
  69. newNode._prev = node;
  70. node._next = newNode;
  71. return newNode;
  72. }
  73. public Node Find(TValue key)
  74. {
  75. var node = _head;
  76. do {
  77. node = node._next;
  78. } while (node._key != null && !_leq(key, node._key));
  79. return node;
  80. }
  81. public Node Min()
  82. {
  83. return _head._next;
  84. }
  85. public void Remove(Node node)
  86. {
  87. node._next._prev = node._prev;
  88. node._prev._next = node._next;
  89. }
  90. }
  91. }
  92. } // namespace Unity.VectorGraphics.External