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

app与网站的关系做网络调查的网站赚钱

app与网站的关系,做网络调查的网站赚钱,广告传媒公司是做什么的,纷享销客个人主页#xff1a;仍有未知等待探索-CSDN博客 专题分栏#xff1a;C 一、简介 map和set都是关联性容器#xff0c;底层都是用红黑树写的。 特点#xff1a;存的Key值都是唯一的#xff0c;不重复。 map存的是键值对#xff08;Key—Value#xff09;。 set存的是键… 个人主页仍有未知等待探索-CSDN博客 专题分栏C 一、简介 map和set都是关联性容器底层都是用红黑树写的。 特点存的Key值都是唯一的不重复。 map存的是键值对Key—Value。 set存的是键值Key。 二、map/set的模拟实现 map.h #pragma once#include iostream #include RBTree.h using namespace std;templateclass Key, class Value class map {struct MapKeyOfT{const Key operator()(const pairKey, Value e){return e.first;}};public:typedef pairKey, Value PKV;typedef _RBTree_iteratorPKV, PKV*, PKV iterator;iterator begin(){return _t.begin();}iterator end(){return _t.end();}bool insert(const pairKey, Value e){return _t.insert(e);}void inorder(){_t.inorder();} private:RBTreeKey, pairKey, Value, MapKeyOfT _t; };set.h #pragma once#include RBTree.htemplateclass Key class set {struct SetKeyOfT{const Key operator()(const Key e){return e;}}; public :typedef _RBTree_iteratorKey, Key*, Key iterator;iterator begin(){return _t.begin();}iterator end(){return _t.end();}bool insert(const Key e){return _t.insert(e);}void inorder(){_t.inorder();} private:RBTreeKey, Key, SetKeyOfT _t; }; RBTree.h #pragma once#includeiostream using namespace std;enum color {Red,Black }; template class ValueTpye struct RBTreeNode {RBTreeNode(const ValueTpye e ValueTpye()):_left(nullptr),_right(nullptr),_parent(nullptr),_col(Red),_val(e){}struct RBTreeNodeValueTpye* _left;struct RBTreeNodeValueTpye* _right;struct RBTreeNodeValueTpye* _parent;int _col;ValueTpye _val; };templateclass ValueType, class Ptr, class Ref class _RBTree_iterator {typedef RBTreeNodeValueType node;typedef _RBTree_iteratorValueType, Ptr, Ref iterator; public:_RBTree_iterator(node* e):_node(e){}Ptr operator-(){return _node-_val;}Ref operator*(){return _node-_val;}bool operator!(iterator it){return _node ! it._node;}iterator operator(){if (_node-_right){node* left _node-_right;while (left-_left){left left-_left;}_node left;}else{node* cur _node;node* p cur-_parent;while (p cur p-_right){cur p;p p-_parent;}_node p;}return *this;} private:node* _node; };template class Key, class ValueType, class KeyOfT class RBTree { public:typedef RBTreeNodeValueType node;typedef _RBTree_iteratorValueType, ValueType*, ValueType iterator;KeyOfT kot;RBTree():_root(nullptr){}iterator begin(){node* cur _root;while (cur cur-_left){cur cur-_left;}return iterator(cur);}iterator end(){return iterator(nullptr);}node* find(const Key e){node* cur _root;while (cur){if (kot(cur-_val).first e){cur cur-_left;}else if (kot(cur-_val).first e){cur cur-_right;}else{return cur;}}return nullptr;}bool insert(const ValueType e){// 根据二叉搜索树插入的方式进行插入node* cur _root;node* parent cur;while (cur){parent cur;if (kot(cur-_val) kot(e)){cur cur-_left;}else if (kot(cur-_val) kot(e)){cur cur-_right;}else{return false;}}cur new node(e);if (parent nullptr){_root cur;}else{if (kot(parent-_val) kot(cur-_val)){parent-_left cur;}else{parent-_right cur;}cur-_parent parent;}// 更新对于不同的情况进行不同的调整// parent 为黑、不存在结束node* p parent;while (p p-_col Red){node* g p-_parent;if (g-_left p){node* u g-_right;// 叔叔存在且为红if (u u-_col Red){p-_col u-_col Black;g-_col Red;// 继续往上处理cur g;p cur-_parent;}// 叔叔不存在且为黑else {// g// p u// cif (cur p-_left){// 右单旋RotateR(g);// 变色g-_col Red;p-_col Black;}// g// p u// celse {// 左右双旋RotateL(p);RotateR(g);// 变色cur-_col Black;g-_col Red;}// 叔叔不存在或者存在且为黑调整完就不需要继续进行调整了break;}}else{node* u g-_left;if (u u-_col Red){p-_col u-_col Black;g-_col Red;// 继续往上处理cur g;p cur-_parent;}else {// g// u p// cif (cur p-_right){// 左单旋RotateL(g);// 变色g-_col Red;p-_col Black;}// g// u p// celse {// 左右双旋RotateR(p);RotateL(g);// 变色cur-_col Black;g-_col Red;}// 叔叔不存在或者存在且为黑调整完就不需要继续进行调整了break;}}}_root-_col Black;return true;}void inorder(){_inorder(_root);} private:void _inorder(node* root){if (root nullptr) return;_inorder(root-_left);cout kot(root-_val) ;_inorder(root-_right);}void RotateR(node* parent){node* subl parent-_left;node* sublr subl-_right;node* grandfather parent-_parent;parent-_left sublr;if (sublr){sublr-_parent parent;}subl-_right parent;parent-_parent subl;subl -_parent grandfather;if (_root parent){if (grandfather-_left parent){grandfather-_left subl;}else{grandfather-_right subl;}}else{_root subl;}}void RotateL(node* parent){node* subr parent-_right;node* subrl subr-_left;node* grandfather parent-_parent;parent-_right subrl;if (subrl){subrl-_parent parent;}subr-_left parent;parent-_parent subr;subr -_parent grandfather;if (_root ! parent){if (grandfather-_left parent){grandfather-_left subr;}else{grandfather-_right subr;}}else{_root subr;}}private:node* _root; }; main.cpp测试 #define _CRT_SECURE_NO_WARNINGS 1#include map.h #include set.h //#include map //#include set #include iostream using namespace std;void test1() {int a[] {5, 3, 7, 3, 7, 8, 4, 2, 9, 10};mapint, int m;for (int e : a){m.insert(make_pair(e, e));}m.inorder(); }void test2() {int a[] {5, 3, 7, 3, 7, 8, 4, 2, 9, 10};setint s;for (int e : a){s.insert(e);}s.inorder(); }void test3() {int a[] {5, 3, 7, 3, 7, 8, 4, 2, 9, 10};setint s;for (int e : a){s.insert(e);}auto it s.begin();while (it ! s.end()){cout *it endl; it;} }void test4() {pairint, int a[] {{5, 5}, {3, 3}, {7, 7}, {3, 3}, {7, 7}, {8, 8}, {4, 4}, {2, 2}, {9, 9}, {10, 10}};setpairint, int s;for (auto e : a){s.insert(e);}auto it s.begin();while (it ! s.end()){cout (*it).first (*it).second endl; it;} } int main() {test1();return 0; }
http://www.pierceye.com/news/88268/

相关文章:

  • sz住房和城乡建设部网站在线flash相册网站源码
  • 网站开发工具 n优秀网站建设空间
  • 做攻略的网站做gif动态图网站
  • 营销型网站设计公司哪里有网站研发进度表下载
  • 快速制作网站网页设计入门首先要学什么
  • 微商城网站建设平台合同网站建设业务客户来源
  • 如何自己做摄影网站微信二维码无法打开网页 为什么
  • 兰州学校网站建设专业网站制作的费用
  • 企业软件网站建设中国成熟iphone
  • 重庆建立公司网站androidstudio安装教程
  • 设计个网站需要怎么做建设集团有限公司简介
  • 商城网站建设缺点瑞安营销网站建设
  • 山东网站定制策划广告网址
  • 自己开网站需要什么最后两年会出妖
  • 高校学风建设专栏网站建设一批适合青少年的网站
  • 新竹网站wordpress 301怎么写
  • 企业网站管理系统演示平台用jsp做网站的体会
  • 域名不转出可以做网站吗万州网
  • 辽宁市营商环境建设局网站精准营销五个步骤
  • 网站新闻标题字数网站的内容与功能设计
  • 网站模版 免费下载影响网站速度的因素
  • 做百度推广一定要有自已网站百度推广做网站吗
  • 可口可乐网站建设策划方案做网络竞拍的网站需要什么
  • 免费做ppt的网站有哪些wordpress ajax 接口
  • 中文网站建设教程焦作建设网站哪家好
  • 站长工具app官方下载wordpress 文件夹改名
  • 把网站内容全删掉 在重新建立会不会被k江苏中南建设集团网站是多少
  • 网站负责人备案采集照具体要求网站后台管理系统需求
  • 公司网站域名备案流程网站关键词优化原理
  • 海外sns网站网络软文营销的案例