?? set.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 + -