/// <summary> /// 拓扑排序 /// </summary> /// <typeparam name="valueType">数据类型</typeparam> /// <param name="edges">边集合</param> /// <param name="points">无边点集合</param> /// <param name="isDesc">是否反向排序</param> /// <returns>排序结果</returns> public static valueType[] Sort <valueType>(ICollection <KeyValue <valueType, valueType> > edges, HashSet <valueType> points, bool isDesc = false) where valueType : IEquatable <valueType> { if (edges.count() == 0) { return(points.getArray()); } Dictionary <valueType, ListArray <valueType> > graph = DictionaryCreator.CreateAny <valueType, ListArray <valueType> >(); if (points == null) { points = HashSetCreator.CreateAny <valueType>(); } ListArray <valueType> values; foreach (KeyValue <valueType, valueType> edge in edges) { if (!graph.TryGetValue(edge.Key, out values)) { graph.Add(edge.Key, values = new ListArray <valueType>()); } values.Add(edge.Value); points.Add(edge.Value); } LeftArray <valueType> pointList = new LeftArray <valueType>(points.Count); foreach (valueType point in points) { if (!graph.ContainsKey(point)) { pointList.UnsafeAdd(point); } } return(new Sorter <valueType>(graph, ref pointList, isDesc).Sort()); }
/// <summary> /// TCP 注册服务客户端 /// </summary> /// <param name="serviceName">TCP 注册服务服务名称</param> private Client(ref HashString serviceName) { #if NoAutoCSer throw new Exception(); #else this.serviceName = serviceName; servers = HashSetCreator.CreateAny <IServer>(); registerClient = new Server.TcpInternalClient(TcpInternalServer.ServerAttribute.GetConfig(serviceName, typeof(AutoCSer.Net.TcpRegister.Server))); logHandle = onLog; checkSocketVersion = registerClient._TcpClient_.CreateCheckSocketVersion(onNewSocket); #endif }