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

📄 strlist.cpp

📁 Decompilation Dos Program is a technique that allows you to recover lost source code. It is also nee
💻 CPP
字号:
#include "StrList.h"
StringList::StringList()
{
  Data = NULL;
  Next = NULL;
  addr = -1;
}
StringList::~StringList()
{
  if (Data) delete[] Data;
  Data=NULL;
  if (Next) delete Next;
  Next=NULL;
}
StringList *StringList::GetList(int Pos)
{
   StringList *ptr = this;
   while(Pos--)
     ptr = ptr->Next;
   return ptr;
}
int StringList::GetPos(StringList *s)
{
   StringList *ptr = this;
   int pos=0;
   do
   {
     if (ptr==s) return pos;
     ptr = ptr->Next;
     pos++;
   }while(ptr);
   return -1;
}
void StringList::Replace(const char *t)
{
  if (Data) delete[] Data;
  Data = NULL;
  Add(t,addr);
}
void StringList::Add(const char *t,int _addr)
{
  if (Data)
  {
    if (!Next) Next = new StringList;
    Next->Add(t,_addr);
  }
  else
  {
    Data = new char[strlen(t)+1];
    assert(Data);
    strcpy(Data,t);
    addr=_addr;
  }
}
/*-------------------------------------------------------------
Insert - inserts the given string in the current position and
 pushes everything else down by one unit.
*** Data in 'this' stringlist is replaced by the new one.
-------------------------------------------------------------*/
void StringList::Insert(const char *t)
{
  if (Data)
  {
    StringList *tmp = Next;
    Next = new StringList;
    Next->Add(Data,addr);
    Next->Next = tmp;
    delete[] Data;
    Data=NULL;
  }
  Add(t);
}
void StringList::Delete(StringList *s)
{
  assert(s!=this);
  StringList *ptr = this;
  while(ptr->Next!=s) ptr = ptr->Next;
  ptr->Next = s->Next;
  s->Next = NULL;
  delete s;
}

⌨️ 快捷键说明

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