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

📄 sitem.cs

📁 图档管理系通
💻 CS
字号:
using System;

namespace sys_3
{
	/// <summary>
	/// sItem 的摘要说明。
	/// </summary>
	/// 
	public struct Item
	{
			public string x,y;
			public Item(string x,string y)
			{
				this.x=x.ToString(); this.y=y.ToString();
			
			}
		    
	}
	public class sItem
	{
		public sItem(int cc)
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			count=0;
				list=new Item[cc];
		}
		public sItem()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			count=0;
			list=new Item[10];
		}
		private Item[] list;
		
		public object this[int index]
		{
			get
			{
				return list[index];
			}
			set
			{
				list[index]=(Item)value;
			}
		
		}
		
		public int count;
		public void add(Item a)
		{
			bool flag=false;
			if(count==0)
			{
				list[count]=a;
				count++;
			}
			else 
			{
				for(int i=0;i<count;i++)
				{
					if(list[i].Equals(a))//list[i].x==a.x && list[i].y==a.y)//
					{
						flag=true;
						break;
					}
				}
				if(flag==false)
				{
					list[count]=a;//可能和c不一样!!!
					count++;
				}
			}
		}
		
		public void delete(Item a)
		{
			for(int i=0;i<count;i++)
			{
				if(list[i].x==a.x && list[i].y==a.y)//list[i].Equals(a))
				{
					//为了减少时间复杂度 在这里浪费一点空间!
					Item x=new Item("xxxx","xxxx");
					list[i]=x;
					
				}
			}
		}

		public void clear()
		{
			count=0;//费项交给垃圾回收站,就不释放了
		}
		public void makeup()
		{
			Item a=new Item("xxxx","xxxx");
			for(int i=count-1;i>-1;i--)
			{
				if(list[i].Equals(a))
				{
					for(int j=i+1;j<count;j++)
					{
						list[j-1]=list[j];
					}
					count--;
				}
			}
		}


	}
}

⌨️ 快捷键说明

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