?? point.cs
字號:
using System;
namespace ClusterLibrary
{
/// <summary>
/// Summary description for Point.
/// </summary>
public class Point : System.Collections.ArrayList
{
// 撈 Point啊 加秦 樂綽 Cluster甸狼 府膠飄 函薦撈促.
private System.Collections.ArrayList cluster_list;
/// <summary>
/// Point狼 積己磊 ( ROW 單撈磐甫 歷厘竅綽 Point )
/// </summary>
/// <param name="nClusters"> Point啊 加秦 樂綽 (int) Cluster甸狼 骯薦 </param>
public Point(int nClusters)
{
// 撈 Point啊 加秦 樂綽 Cluster甸狼 府膠飄甫 積己茄促.
// nClusters綽 撈 Point啊 加秦 樂綽 Cluster甸狼 骯薦撈促.
this.cluster_list = new System.Collections.ArrayList( nClusters );
}
/// <summary>
/// Point狼 積己磊 ( 單撈磐 拌魂 苞瀝 吝埃俊 積扁綽 Point )
/// </summary>
public Point()
{
}
/// <summary>
/// Point啊 加秦 樂綽 Cluster狼 瀝焊甫 歷厘茄促.
/// </summary>
/// <param name="n"></param>
public void SetClusterInfo( int n )
{
this.cluster_list.Add( n );
}
/// <summary>
/// Point啊 n鍋擄 Set俊輯 割鍋擄 Cluster俊 加竅綽瘤 弊 藹闌 府畔茄促.
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public int GetClusterInfo( int n )
{
return (int) this.cluster_list[n];
}
/// <summary>
/// Point啊 加秦 樂綽 Cluster狼 瀝焊甫 歷厘茄促.
/// </summary>
/// <param name="n"></param>
public void SetClusterInfo( int[] n )
{
this.AddRange( n );
}
/// <summary>
/// Point1苞 Point2甫 歹竅綽 Operator
/// </summary>
/// <param name="pt1"></param>
/// <param name="pt2"></param>
/// <returns></returns>
public static Point operator + ( Point pt1, Point pt2 ) {
Point addResult = new Point();
if ( pt1.Count > pt2.Count ){
for ( int i = 0; i < pt1.Count ; i ++ ){
addResult.Add ( (double) pt1[i] );
}
return addResult;
}else if ( pt1.Count< pt2.Count ){
for ( int i = 0; i < pt2.Count; i ++ ){
addResult.Add( (double) pt2[i] );
}
return addResult;
}
try{
for ( int i = 0; i < pt1.Count ; i++ ){
addResult.Add( (double)pt1[i] + (double)pt2[i] );
}
}
catch ( System.Exception e ){
System.Console.WriteLine( (e.StackTrace) );
System.Console.WriteLine( e.ToString() );
}
return addResult;
}
/// <summary>
/// Point1苞 Point2甫 嘩綽 Operator
/// </summary>
/// <param name="pt1"></param>
/// <param name="pt2"></param>
/// <returns></returns>
public static Point operator - ( Point pt1, Point pt2 ) {
Point minusResult = new Point();
if ( pt1.Count > pt2.Count ){
for ( int i = 0; i < pt1.Count ; i++){
minusResult.Add( (double)pt1[i] );
}
return minusResult;
}else if ( pt1.Count < pt2.Count ){
for ( int i = 0; i < pt2.Count ; i++){
minusResult.Add( (double)pt1[i] );
}
}
try{
for ( int i = 0; i < pt1.Count ; i++ ){
minusResult.Add( (double)pt1[i] - (double)pt2[i] );
}
}
catch ( System.Exception e ){
System.Console.WriteLine( (e.StackTrace) );
System.Console.WriteLine( e.ToString() );
}
return minusResult;
}
/// <summary>
/// Point狼 阿 諒釬藹闌 (double)n欄肺 唱穿綽 竊薦
/// </summary>
/// <param name="pt"></param>
/// <param name="n"></param>
/// <returns> 唱床柳 Point狼 藹 </returns>
public static Point operator / (Point pt, double n ){
Point divideResult = new Point();
for ( int i = 0; i < pt.Count ; i ++ ){
divideResult.Add( (double) pt[i] / n );
}
return divideResult;
}
/// <summary>
/// Point狼 阿 諒釬藹闌 (double) n鉸 竅綽 竊薦
/// </summary>
/// <param name="pt"></param>
/// <param name="n"></param>
/// <returns> (double) n鉸茄 Point狼 藹 </returns>
public static Point operator ^ (Point pt, double n ){
Point powResult = new Point();
for ( int i = 0; i < pt.Count; i++ ){
powResult.Add( System.Math.Pow((double) pt[i], n ));
}
return powResult;
}
/// <summary>
/// Point狼 農扁甫 Return 竅綽 竊薦 for J#
/// </summary>
/// <returns></returns>
public int size(){
return this.Count;
}
/// <summary>
/// Point狼 Indexer for J#
/// </summary>
new public double this[int index]{
set {
if ( index > this.Count )
throw new Exception ( "Index out of range." );
else
base[index] = value;
}
get {
if ( index > this.Count )
throw new Exception ( "Index out of range." );
else
return (double)base[index];
}
}
/// <summary>
/// Point俊 甸絹樂綽 諒釬甫 波晨
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public double GetPoint( int index ){
if ( index >= this.Count )
throw new Exception ( "Index out of range." );
return (double)this[index];
}
/// <summary>
/// Point俊 甸絹樂綽 諒釬甫 波晨 for J#
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public double getValueAt( int index ){
return this.GetPoint( index );
}
public bool IsEmpty(){
return ( this.size() == 0 );
}
public void addValue( double number ){
this.Add( number );
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -