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

📄 mhwndlist.cpp

📁 课程设计中的虚拟桌面设计
💻 CPP
字号:
#include "stdafx.h"
#include "mHwndList.h"
d_list::d_list()
{
 d_nCount=0;
 now_pos=0;
 head=new node;
 head->d_h=NULL;
 head->d=-1; 
 head->next=NULL;
 tail=head;
}

d_list::~d_list()
{
	node *temp=head->next,*m_head;
	while(temp!=NULL)
	{
      m_head=temp->next;  
      delete temp;
      d_nCount--;
	  temp=m_head;
	}
	tail=head;
}

void d_list::get()
{
	node *temp=head->next,*m_head;
	while(temp!=NULL)
	{
      m_head=temp->next;  
      delete temp;
      d_nCount--;
	  temp=m_head;
	}
	tail=head;
}

int d_list::d_insert(HWND h,int n)
{	
  node *temp=new node;
  temp->d_h=h;
  temp->d=n;
  temp->next=NULL;
  tail->next=temp;
  tail=temp;
  d_nCount++;
  return 0;
}

int d_list::d_delete(HWND h,int n)
{ 
  node *temp=head->next,*pre;
  while(temp->d_h!=h)
  {
   pre=temp;
   temp=temp->next;
  }
  if(temp)
  {
	  pre->next=temp->next;
	  delete temp;
	  d_nCount--;
  }
  return 0;
}

int d_list::d_haveSame(HWND h)
{
 int n=0; 
 node *temp=head->next;
  while(temp->d_h!=h)
  {
   temp=temp->next;
   n++;
  }
  if(temp!=NULL)
	  return n;
     else 
	  return -1;
}

HWND d_list::d_read(int n)
{
    node *temp=head;
	while(n>0)
	{
	 temp=temp->next; 
     n--;
	}

	return temp->d_h;
}

int d_list::d_getnCount()
{
	return d_nCount;
}

d_list &d_list::operator =(d_list &m_list)
{  // this->~d_list();
	this->get();
    int d=m_list.d_getnCount();
	int i=1;
	while(i<=d)
	{
      this->d_insert(m_list.d_read(i++),0);
	}
	return *this;
}

int d_list::d_comp(d_list &m_list)
{
 int i1=this->d_getnCount();
 int i2=m_list.d_getnCount();
 int i3=1,i4=1;
 int temp;
                                             //前者与后者比较
 
    temp=i1;
    while(i3<=i2)
	{
        while(i1>=1)
		{
         if(this->d_read(i1)==m_list.d_read(i3)) 
		 {
		   m_list.d_setpos(i3,1);            //找到了
		   break;
		 }
		   i1--;
		}
		if(i1==0)
		   m_list.d_setpos(i3,0);            //没找到
           i1=temp;
		   i3++;
	}
 
                                             //后者与前者相比较
	 i1=this->d_getnCount();
     i2=m_list.d_getnCount();
	 temp=i2;
    while(i4<=i1)
	{ 
        while(i2>=1)
		{
         if(this->d_read(i4)==m_list.d_read(i2)) 
		 {
			 this->d_setpos(i4,1);              //找到了
		     break;
		 }
		 i2--;
		}
		if(i2==0)
		   this->d_setpos(i4,0);            //没找到
		   i2=temp;
		   i4++;
	}

  return 0;
}

int d_list::d_setpos(int n,int num)
{
  node *temp=head;
	while(n>0)
	{
	 temp=temp->next; 
     n--;
	}
    temp->d=num; 
	return 0;
}

int d_list::d_read_add(d_list &m_list,int way)
{  int i=1;
   node *temp=head->next;
   while(i<=d_nCount)
   {
    if((way==0)&&(temp!=NULL)&&(temp->d==0))
      m_list.d_delete(temp->d_h,0);
	if((way==1)&&(temp!=NULL)&&(temp->d==0))
	  m_list.d_insert(temp->d_h,0); 
	
	temp=temp->next;
	i++;
   }
   return 0;
}

⌨️ 快捷键说明

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