IMap.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export type ForeachMapAction<K, V> = (key: K, value: V) => void;
  2. /**
  3. * IMap接口
  4. */
  5. export interface IMap<K, V> {
  6. /**
  7. * 数量
  8. */
  9. Count(): number;
  10. /**
  11. * 添加
  12. * @param key Key
  13. * @param value Value
  14. * @return Value
  15. */
  16. Add(key: K, value: V): V;
  17. /**
  18. * 移除
  19. * @param key Key
  20. * @return Value
  21. */
  22. Remove(key: K): V;
  23. /**
  24. * 修改已有Key的Value值
  25. * @param key Key
  26. * @param value New Value
  27. * @return True: 修改成功; False: 修改失败
  28. */
  29. Replace(key: K, value: V): boolean;
  30. /**
  31. * 包含
  32. * @param key Key
  33. * @return True: 包含; False: 未包含
  34. */
  35. ContainsKey(key: K): boolean;
  36. /**
  37. * 获取Value
  38. * @param key Key
  39. * @return Value
  40. */
  41. Value(key: K): V;
  42. /**
  43. * 所有Keys
  44. * @return K[]
  45. */
  46. Keys(): K[];
  47. /**
  48. * 所有Values
  49. * @return V[]
  50. */
  51. Values(): V[];
  52. /**
  53. * 迭代
  54. * @param callback 回调
  55. */
  56. Foreach(callback: ForeachMapAction<K, V>, thisArg?: any): void;
  57. /**
  58. * 清空
  59. */
  60. Clear(): void;
  61. }