⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set.cs

📁 Cluster validation program
💻 CS
字号:
using System;

namespace ClusterLibrary
{
	/// <summary>
	/// Summary description for Set.
	/// </summary>
	public class Set : System.Collections.ArrayList
	{
		// Point甸阑 葛滴 历厘窍绰 府胶飘
		System.Collections.ArrayList	m_PointList;

		/// <summary>
		/// Set阑 历厘窍绰 Class
		/// </summary>
		public Set()
		{
			//
			// TODO: Add constructor logic here
			//
			this.m_PointList	=	new System.Collections.ArrayList();
		}

		/// <summary>
		/// 傈眉 单捞磐狼 乞闭阑 备窃
		/// </summary>
		/// <returns></returns>
		public Point Center(){
			Cluster clTemp;
			Point	ptTemp = new Point();
			int number = 0;
			for ( int i = 0; i < this.Count ; i ++ ){
				clTemp = (Cluster)this[i];
				number += clTemp.Count;
				for ( int j = 0; j < clTemp.Count ; j ++ ){
					ptTemp = ptTemp + (Point)clTemp[j];
				}
			}

			return ptTemp / (double)number;
		}

		/// <summary>
		/// 傈眉 单捞磐狼 乞闭阑 备窃 for J#
		/// </summary>
		/// <returns></returns>
		public Point weight_center(){
			return this.Center();
		}

		/// <summary>
		/// Point甫 罐酒辑 Cluster甫 积己窍搁辑 Set狼 单捞磐甫 父电促.
		/// </summary>
		/// <param name="i"> 割锅掳 Set牢瘤 唱鸥郴绰 Index </param>
		/// <param name="point"> 涝仿且 Point </param>
		public void AddPoint( int index, ClusterLibrary.Point point ){
			// 老窜 傈眉 Point List俊 历厘茄促
			this.m_PointList.Add( point );

			ClusterLibrary.Cluster clTemp;
			for ( int i = 0; i < this.Count ; i ++ ){
				clTemp = (Cluster) this[i];
				// 货肺 Add且 Point 沥焊客 泅犁 父甸绢柳 Cluster甫 厚背茄促.
				if ( clTemp.index != index ) {
					// Point啊 啊福虐绰 Cluster Index客 促福搁 促弗 Cluster甫 厚背茄促.
					continue;
				}
				else{
					// Point啊 啊福虐绰 Cluster Index啊 捞固 粮犁茄促搁 弊 Cluster俊 Point甫 器窃矫挪促.
					clTemp.Add( point );
					return;
				}
			}
			// Point啊 啊福虐绰 Cluster Index啊 泅犁 粮犁窍绰 Cluster郴俊 绝阑 锭 货肺款 Cluster甫 父电促.
			clTemp = new ClusterLibrary.Cluster( index );
			// 货肺 父电 Cluster甫 Set俊 器窃矫挪促.
			this.Add( clTemp );
			// Point蔼阑 货肺 父电 Cluster俊 器窃茄促.
			clTemp.Add( point );
		}

		/// <summary>
		/// Set狼 农扁甫 Return 窍绰 窃荐 for J#
		/// Number of Points
		/// </summary>
		/// <returns></returns>
		public int size(){
			int count	=	0;
			foreach (Cluster cl in this) {
				count	+=	cl.Count;
			}
			return count;
		}

		/// <summary>
		/// Set俊 甸绢乐绰 Point甫 波晨
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Cluster GetPoint( int index ){
			if ( index >= this.Count )
				throw new Exception ( "Index out of range." );
			return (ClusterLibrary.Cluster)this[index];
		}

		/// <summary>
		/// Set俊 甸绢乐绰 Point甫 波晨 for J#
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public Cluster getValueAt( int index ){
			return this.GetPoint( index );
		}

		public void	addElement( Cluster cl ){
			this.Add(cl);
		}

		public Cluster elementAt(int index ){
			return this.GetPoint(index);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -