上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 28 下一页
摘要: vector和array的使用非常相似,区别是vector是动态空间,随着新元素的介入,靠内部机制就可以自动扩充空间以容纳新元素vector的迭代器:由于vector维护的是一个线性空间,所以可以用普通指针作为迭代器。指针也具备随即存取能力,因此vector提供随机访问迭代器。vector的数据结构:线性连续空间。用start和finish指向目前已经被使用的范围中的头尾,并且以迭代器end_of_storage指向整块连续空间(包括备用空间)的末尾。vector实际分配的空间一定大于等于需要的空间,以备将来的扩充。capacity的概念。vector的构造与管理:vector缺省使用allo 阅读全文
posted @ 2012-04-21 16:15 w0w0 阅读(198) 评论(0) 推荐(0)
摘要: STL的中心思想在于:将数据容器与算法分开,彼此独立设计,然后用胶合剂将他们撮合在一起。迭代器最重要的操作就是对operator*和operator->进行重载为了不暴露容器的内部实现细节,每一种容器都有专属的迭代器,这样就可以把所有的实现细节封装起来不被使用者看到。在迭代器的设计上使用泛型思想:当算法中需要声明一个变量,要用到迭代器所指向的对象的类别(value_type)==>使用参数推到机制万一需要把该类型用于函数的传回值==>声明一个内嵌类型,使用关键词typename但并不是所有的指针类型都是class,如果是原生指针就无法定义内嵌类型==>在泛化设计中提供一 阅读全文
posted @ 2012-04-21 14:24 w0w0 阅读(253) 评论(0) 推荐(0)
摘要: STL源码剖析学习二:空间配置器(allocator)标准接口:vlaue_typepointerconst_pointerreferenceconst_referencesize_typedifference_typerebindallocator()--default constructorallocator(const allocator<U>&--copy constructor~allocator()--destructoraddress(reference x)const--return address of elemaddress(const_referenc 阅读全文
posted @ 2012-04-21 13:24 w0w0 阅读(249) 评论(0) 推荐(0)
摘要: STL源码剖析学习一:概论STL所实现的,是依据泛型思维架设起来的一个概念结构。这个以抽象概为主体而非以实际类为主体的结构,形成一个严谨的接口标准。在此接口之下,任何组件都有最大的独立性,并以迭代器胶合起来,或者以配接器互相连接,或者用仿函数动态选择某种策略。六大组件:1.容器:各种数据结构2.算法3.迭代器:容器和算法之间的胶合剂 是“泛型指针”4.仿函数:行为类似函数,可以作为算法的某种策略5.配接器:修饰容器或者仿函数或者迭代器接口的东西6.配置器:负责空间配置和动态管理语法要点:1.静态常量可以在class内部直接初始化一般的变量都是不能在class内部直接初始化的,即使是常量也不行常 阅读全文
posted @ 2012-04-21 11:16 w0w0 阅读(160) 评论(0) 推荐(0)
摘要: 刚学完《STL程序员开发指南》把算法中常用的函数列一下,备查把常用到的STL算法列下 备查非修正序列算法:对原序列不进行修改,功能是查找比较为主adjacent_find查找相同的相邻元素 反悔第一个元素的迭代器find查找元素 还有find系列查找函数find_first_offind_endfind_last_of....count统计相同元素的个数count_ifmismatch返回pair<第一个序列的迭代器,第二个序列的迭代器>表明第一处不相符合的位置equal比较容器中的元素是否相同for_each非常常用,遍历序列,并对序列中每个元素采用仿函数中定义的操作search 阅读全文
posted @ 2012-04-19 11:41 w0w0 阅读(265) 评论(0) 推荐(0)
摘要: SquaresTime Limit: 3500MSMemory Limit: 65536KTotal Submissions: 10585Accepted: 3825DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same polygon. It is not 阅读全文
posted @ 2011-12-17 16:57 w0w0 阅读(151) 评论(0) 推荐(0)
摘要: Shortest PrefixesTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 7814Accepted: 3297DescriptionA prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "ca 阅读全文
posted @ 2011-12-17 16:56 w0w0 阅读(213) 评论(0) 推荐(0)
摘要: The PeanutsTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 6217Accepted: 2614DescriptionMr. Robinson and his pet monkey Dodo love peanuts very much. One day while they were having a walk on a country road, Dodo found a sign by the road, pasted with a small piece of paper, saying "Free 阅读全文
posted @ 2011-12-17 09:45 w0w0 阅读(194) 评论(0) 推荐(0)
摘要: Parallelogram CountingTime Limit: 5000MSMemory Limit: 65536KTotal Submissions: 5130Accepted: 1699DescriptionThere are n distinct points in the plane, given by their integer coordinates. Find the number of parallelograms whose vertices lie on these points. In other words, find the number of 4-element 阅读全文
posted @ 2011-12-17 09:45 w0w0 阅读(253) 评论(0) 推荐(0)
摘要: Flooded!Time Limit: 1000MSMemory Limit: 30000KTotal Submissions: 3884Accepted: 1258Special JudgeDescriptionTo enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients with the elevation of each 10-meter by 10-meter square of land in regions where homes may be pu 阅读全文
posted @ 2011-12-17 09:44 w0w0 阅读(214) 评论(0) 推荐(0)
摘要: Hardwood SpeciesTime Limit: 10000MSMemory Limit: 65536KTotal Submissions: 12166Accepted: 5000DescriptionHardwoods are the botanical group of trees that have broad leaves, produce a fruit or nut, and generally go dormant in the winter. America's temperate climates produce forests with hundreds of 阅读全文
posted @ 2011-12-17 09:43 w0w0 阅读(175) 评论(0) 推荐(0)
摘要: Simply SyntaxTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 4344Accepted: 1912DescriptionIn the land of Hedonia the official language is Hedonian. A Hedonian professor had noticed that many of her students still did not master the syntax of Hedonian well. Tired of correcting the many synta 阅读全文
posted @ 2011-12-17 09:42 w0w0 阅读(163) 评论(0) 推荐(0)
摘要: Stockbroker GrapevineTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 18507Accepted: 10010DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in th 阅读全文
posted @ 2011-12-14 21:46 w0w0 阅读(144) 评论(0) 推荐(0)
摘要: BUY LOW, BUY LOWERTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 6117Accepted: 2104DescriptionThe advice to "buy low" is half the formula to success in the bovine stock market.To be considered a great investor you must also follow this problems' advice: "Buy low; buy lo. 阅读全文
posted @ 2011-12-12 13:01 w0w0 阅读(183) 评论(0) 推荐(0)
摘要: Testing the CATCHERTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 11400Accepted: 4113DescriptionA military contractor for the Department of Defense has just completed a series of preliminary tests for a new defensive missile called the CATCHER which is capable of intercepting multiple inco 阅读全文
posted @ 2011-12-12 13:00 w0w0 阅读(173) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 28 下一页