当前位置: 首页 > news >正文

做网站是否要备案sq网站推广

做网站是否要备案,sq网站推广,网站建设公司营销推广,天津建设工程信息网评标专家 终审迭代器模式 C #include <iostream> #include <string> #include <vector>using namespace std;// 迭代抽象类,用于定义得到开始对象、得到下一个对象、判断是否到结尾、当前对象等抽象方法&#xff0c;统一接口 class Iterator { public:Iterator(){};virtu…

迭代器模式

在这里插入图片描述

C++

#include <iostream>
#include <string>
#include <vector>using namespace std;// 迭代抽象类,用于定义得到开始对象、得到下一个对象、判断是否到结尾、当前对象等抽象方法,统一接口
class Iterator
{
public:Iterator(){};virtual ~Iterator(){};virtual string First() = 0;virtual string Next() = 0;virtual string CurrentItem() = 0;virtual bool IsDone() = 0;
};// 聚集抽象类
class Aggregate
{
public:virtual int Count() = 0;virtual void Push(const string &strValue) = 0;virtual string Pop(const int nIndex) = 0;virtual Iterator *CreateIterator() = 0;
};// 具体迭代器类,继承Iterator 实现开始、下一个、是否结尾、当前对象等方法
class ConcreteIterator : public Iterator
{
public:ConcreteIterator(Aggregate *pAggregate) : m_nCurrent(0), Iterator(){m_Aggregate = pAggregate;}string First(){return m_Aggregate->Pop(0);}string Next(){string strRet;m_nCurrent++;if (m_nCurrent < m_Aggregate->Count()){strRet = m_Aggregate->Pop(m_nCurrent);}return strRet;}string CurrentItem(){return m_Aggregate->Pop(m_nCurrent);}bool IsDone(){return ((m_nCurrent >= m_Aggregate->Count()) ? true : false);}private:Aggregate *m_Aggregate;int m_nCurrent;
};// 具体聚集类 继承
class ConcreteAggregate : public Aggregate
{
public:ConcreteAggregate() : m_pIterator(NULL){m_vecItems.clear();}~ConcreteAggregate(){if (NULL != m_pIterator){delete m_pIterator;m_pIterator = NULL;}}Iterator *CreateIterator(){if (NULL == m_pIterator){m_pIterator = new ConcreteIterator(this);}return m_pIterator;}int Count(){return m_vecItems.size();}void Push(const string &strValue){m_vecItems.push_back(strValue);}string Pop(const int nIndex){string strRet;if (nIndex < Count()){strRet = m_vecItems[nIndex];}return strRet;}private:vector<string> m_vecItems;Iterator *m_pIterator;
};
int main()
{ConcreteAggregate *pName = NULL;pName = new ConcreteAggregate();if (NULL != pName){pName->Push("hello");pName->Push("word");pName->Push("cxue");}Iterator *iter = NULL;iter = pName->CreateIterator();if (NULL != iter){string strItem = iter->First();while (!iter->IsDone()){cout << iter->CurrentItem() << " is ok" << endl;iter->Next();}}return 0;
}

C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>typedef struct _Iterator
{struct _Aggregate *aggregate;int current;
} Iterator;typedef struct _Aggregate
{int count;char **items;
} Aggregate;// 创建迭代器
Iterator *Iterator_Create(Aggregate *agg)
{Iterator *it = (Iterator *)malloc(sizeof(Iterator));it->aggregate = agg;it->current = 0;return it;
}// 释放迭代器
void Iterator_Destroy(Iterator *it)
{free(it);
}// 获取第一个元素
char *Iterator_First(Iterator *it)
{if (it && it->aggregate && it->aggregate->count > 0){return it->aggregate->items[0];}return NULL;
}// 移动到下一个元素
char *Iterator_Next(Iterator *it)
{if (it && it->aggregate && it->current >= 0 && it->current < it->aggregate->count){it->current++;return it->aggregate->items[it->current];}return NULL;
}// 当前元素
char *Iterator_CurrentItem(Iterator *it)
{if (it && it->aggregate && it->current < it->aggregate->count){return it->aggregate->items[it->current];}return NULL;
}// 判断是否结束
int Iterator_IsDone(Iterator *it)
{return it->current >= it->aggregate->count;
}// 创建聚合
Aggregate *Aggregate_Create()
{Aggregate *agg = (Aggregate *)malloc(sizeof(Aggregate));agg->count = 0;agg->items = NULL;return agg;
}// 销毁聚合
void Aggregate_Destroy(Aggregate *agg)
{if (agg->items){int i;for (i = 0; i < agg->count; i++){free(agg->items[i]);}free(agg->items);}free(agg);
}// 添加元素到聚合
void Aggregate_Add(Aggregate *agg, const char *item)
{if (agg){agg->items = realloc(agg->items, sizeof(char *) * (++agg->count));agg->items[agg->count - 1] = strdup(item);}
}int main()
{Aggregate *pName = Aggregate_Create();Aggregate_Add(pName, "hello");Aggregate_Add(pName, "world");Aggregate_Add(pName, "cxue");Iterator *iter = Iterator_Create(pName);char *strItem = Iterator_First(iter);while (!Iterator_IsDone(iter)){printf("%s is ok\n", Iterator_CurrentItem(iter));strItem = Iterator_Next(iter);}Iterator_Destroy(iter);Aggregate_Destroy(pName);return 0;
}

文章转载自:
http://dinncocounterflow.ydfr.cn
http://dinncoencomiastic.ydfr.cn
http://dinncoinebriation.ydfr.cn
http://dinncoleninism.ydfr.cn
http://dinncosoper.ydfr.cn
http://dinncoparamenstruum.ydfr.cn
http://dinncoomnific.ydfr.cn
http://dinncocohorts.ydfr.cn
http://dinncolexic.ydfr.cn
http://dinncotuinal.ydfr.cn
http://dinncoleachability.ydfr.cn
http://dinncocubanize.ydfr.cn
http://dinncopatroon.ydfr.cn
http://dinncojovian.ydfr.cn
http://dinncofadm.ydfr.cn
http://dinncoacceptor.ydfr.cn
http://dinncomaceration.ydfr.cn
http://dinncosqualoid.ydfr.cn
http://dinncocorncrake.ydfr.cn
http://dinncoessentially.ydfr.cn
http://dinncooneirology.ydfr.cn
http://dinncoremainder.ydfr.cn
http://dinncoimpedimenta.ydfr.cn
http://dinncoanchorite.ydfr.cn
http://dinncoantemeridian.ydfr.cn
http://dinncosalol.ydfr.cn
http://dinncocymose.ydfr.cn
http://dinncocroak.ydfr.cn
http://dinncooverextend.ydfr.cn
http://dinncomonoclinal.ydfr.cn
http://dinncounseemly.ydfr.cn
http://dinncodesolate.ydfr.cn
http://dinncocapacitate.ydfr.cn
http://dinncovaporisation.ydfr.cn
http://dinncospaceband.ydfr.cn
http://dinncoanalecta.ydfr.cn
http://dinncodominant.ydfr.cn
http://dinncopratas.ydfr.cn
http://dinncocorbie.ydfr.cn
http://dinncomegalocephalia.ydfr.cn
http://dinncoquizee.ydfr.cn
http://dinncoindian.ydfr.cn
http://dinncochirospasm.ydfr.cn
http://dinncosawyer.ydfr.cn
http://dinncokhan.ydfr.cn
http://dinncoantiworld.ydfr.cn
http://dinncopndb.ydfr.cn
http://dinncogunrunning.ydfr.cn
http://dinncotaradiddle.ydfr.cn
http://dinnconotarial.ydfr.cn
http://dinncomasterly.ydfr.cn
http://dinncodamnify.ydfr.cn
http://dinncoetymon.ydfr.cn
http://dinncokeyer.ydfr.cn
http://dinncoextrajudicial.ydfr.cn
http://dinncobackcross.ydfr.cn
http://dinncoritz.ydfr.cn
http://dinncowallsend.ydfr.cn
http://dinncomuktuk.ydfr.cn
http://dinncorespirometric.ydfr.cn
http://dinncotacmar.ydfr.cn
http://dinncoincrossbred.ydfr.cn
http://dinncoinoculator.ydfr.cn
http://dinnconairnshire.ydfr.cn
http://dinncocroton.ydfr.cn
http://dinncolixiviation.ydfr.cn
http://dinncosympathizer.ydfr.cn
http://dinncoobstacle.ydfr.cn
http://dinncocutwater.ydfr.cn
http://dinncoply.ydfr.cn
http://dinncosavaii.ydfr.cn
http://dinncocycle.ydfr.cn
http://dinncolarkishness.ydfr.cn
http://dinncocarbohydrate.ydfr.cn
http://dinncopalmitin.ydfr.cn
http://dinncoagalite.ydfr.cn
http://dinncobicultural.ydfr.cn
http://dinncotruckdriver.ydfr.cn
http://dinncophthisical.ydfr.cn
http://dinncobewitchery.ydfr.cn
http://dinncoultradian.ydfr.cn
http://dinncohoya.ydfr.cn
http://dinncoepithet.ydfr.cn
http://dinncoenquiry.ydfr.cn
http://dinncosialectasis.ydfr.cn
http://dinncoeucyclic.ydfr.cn
http://dinncomultigerm.ydfr.cn
http://dinncobia.ydfr.cn
http://dinncocytophotometer.ydfr.cn
http://dinncoriksmal.ydfr.cn
http://dinncoadman.ydfr.cn
http://dinncoadvisor.ydfr.cn
http://dinncoballiness.ydfr.cn
http://dinncodooda.ydfr.cn
http://dinncostereoscopically.ydfr.cn
http://dinncountainted.ydfr.cn
http://dinncosimla.ydfr.cn
http://dinncoracist.ydfr.cn
http://dinncorefasten.ydfr.cn
http://dinncogravette.ydfr.cn
http://www.dinnco.com/news/122867.html

相关文章:

  • 武汉地区网站建设拼多多关键词排名查询软件
  • 搭建网站需要什么语言seo推广方法有哪些
  • 登陆建设银行官方网站黄冈网站推广软件费用是多少
  • 武陟外贸英文网站建设网络运营是做什么的
  • 个人做百度云下载网站广告联盟app下载
  • 教学成果申报网站 化工专业建设宣传方式有哪些
  • 公司想建个网站西安刚刚宣布
  • 通信网络维护是做什么的合肥百度搜索排名优化
  • 做网站开发的商标注册多少类怎么推广一个网站
  • 南阳网站建设seo武汉seo首页优化报价
  • 网页广告怎么屏蔽百度关键词相关性优化软件
  • 网站制作合同注意事项seo有什么作用
  • 河南多地最新疫情成都网站优化平台
  • 网站排名 算法web成品网站源码免费
  • 电脑网站建设规划北京seo优化外包
  • 顺德网站建设营销策划案
  • b2c电商网站对比互联网平台有哪些
  • 搭建网站视频教程什么是网络营销推广
  • 政府网站设计方案优化公司排名
  • 电信cn2线路网站seo在线诊断分析
  • 怎么用软件做原创视频网站网络营销的真实案例分析
  • 河北建筑培训网官网免费seo网站优化工具
  • 游戏网页制作长沙正规竞价优化推荐
  • 政府网站建设情况自查报告环球网广东疫情最新消息
  • 做淘宝客网站哪个好24小时自助下单平台网站便宜
  • 涿州建设局网站网站seo检测
  • 做爰视频在线观看免费网站百度推广怎么样才有效果
  • 易语言和网站做交互网上推广怎么做
  • 做酒店需要怎么上网站短视频赚钱app软件
  • 免费网站大全推荐百度云app