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

📄 container.html

📁 ISO_C++:C++_STL开发文档
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><!--  -- Copyright (c) 1996-1999  -- Silicon Graphics Computer Systems, Inc.  --  -- Permission to use, copy, modify, distribute and sell this software  -- and its documentation for any purpose is hereby granted without fee,  -- provided that the above copyright notice appears in all copies and  -- that both that copyright notice and this permission notice appear  -- in supporting documentation.  Silicon Graphics makes no  -- representations about the suitability of this software for any  -- purpose.  It is provided "as is" without express or implied warranty.  --  -- Copyright (c) 1994  -- Hewlett-Packard Company  --  -- Permission to use, copy, modify, distribute and sell this software  -- and its documentation for any purpose is hereby granted without fee,  -- provided that the above copyright notice appears in all copies and  -- that both that copyright notice and this permission notice appear  -- in supporting documentation.  Hewlett-Packard Company makes no  -- representations about the suitability of this software for any  -- purpose.  It is provided "as is" without express or implied warranty.  --  --><Head><Title>Container</Title><!-- Generated by htmldoc --></HEAD><BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 	ALINK="#ff0000"> <IMG SRC="CorpID.gif"      ALT="SGI" HEIGHT="43" WIDTH="151"> <!--end header--><BR Clear><H1>Container</H1><Table CellPadding=0 CellSpacing=0 width=100%><TR><TD Align=left><Img src = "containers.gif" Alt=""   WIDTH = "194"  HEIGHT = "38" ></TD><TD Align=right><Img src = "concept.gif" Alt=""   WIDTH = "194"  HEIGHT = "38" ></TD></TR><TR><TD Align=left VAlign=top><b>Category</b>: containers</TD><TD Align=right VAlign=top><b>Component type</b>: concept</TD></TR></Table><h3>Description</h3>A Container is an object that stores other objects (its <i>elements</i>),and that has methods for accessing its elements.  In particular, every type that is a model of Container has an associated <A href="Iterators.html">iterator</A>type that can be used to iterate through the Container's elements.<P>There is no guarantee that the elements of a Container are storedin any definite order; the order might, in fact, be different uponeach iteration through the Container.  Nor is there a guarantee thatmore than one iterator into a Container may be active at any one time.(Specific types of Containers, such as <A href="ForwardContainer.html">Forward Container</A>, do provide such guarantees.)<P>A Container &quot;owns&quot; its elements: the lifetime of an element stored in a container cannot exceed that of the Container itself. <A href="#1">[1]</A><h3>Refinement of</h3><A href="Assignable.html">Assignable</A><h3>Associated types</h3><Table border><TR><TD VAlign=top>Value type</TD><TD VAlign=top><tt>X::value_type</tt></TD><TD VAlign=top>The type of the object stored in a container.  The value type   must be <A href="Assignable.html">Assignable</A>, but need not be <A href="DefaultConstructible.html">DefaultConstructible</A>. <A href="#2">[2]</A></TD></TR><TR><TD VAlign=top>Iterator type</TD><TD VAlign=top><tt>X::iterator</tt></TD><TD VAlign=top>The type of iterator used to iterate through a container's   elements.  The iterator's value type is expected to be the   container's value type.  A conversion   from the iterator type to the const iterator type must exist.   The iterator type must be an <A href="InputIterator.html">input iterator</A>. <A href="#3">[3]</A></TD></TR><TR><TD VAlign=top>Const iterator type</TD><TD VAlign=top><tt>X::const_iterator</tt></TD><TD VAlign=top>A type of iterator that may be used to examine, but not to modify,   a container's elements. <A href="#3">[3]</A> <A href="#4">[4]</A></TD></TR><TR><TD VAlign=top>Reference type</TD><TD VAlign=top><tt>X::reference</tt></TD><TD VAlign=top>A type that behaves as a reference to the container's value type. <A href="#5">[5]</A></TD></TR><TR><TD VAlign=top>Const reference type</TD><TD VAlign=top><tt>X::const_reference</tt></TD><TD VAlign=top>A type that behaves as a const reference to the container's valuetype. <A href="#5">[5]</A></TD></TR><TR><TD VAlign=top>Pointer type</TD><TD VAlign=top><tt>X::pointer</tt></TD><TD VAlign=top>A type that behaves as a pointer to the container's value type. <A href="#6">[6]</A></TD></TR><TR><TD VAlign=top>Distance type</TD><TD VAlign=top><tt>X::difference_type</tt></TD><TD VAlign=top>A signed integral type used to represent the distance between two   of the container's iterators.  This type must be the same as    the iterator's distance type. <A href="#2">[2]</A></TD></TR><TR><TD VAlign=top>Size type</TD><TD VAlign=top><tt>X::size_type</tt></TD><TD VAlign=top>An unsigned integral type that can represent any nonnegative value   of the container's distance type. <A href="#2">[2]</A></TD></tr></table><h3>Notation</h3><Table><TR><TD VAlign=top><tt>X</tt></TD><TD VAlign=top>A type that is a model of Container</TD></TR><TR><TD VAlign=top><tt>a</tt>, <tt>b</tt></TD><TD VAlign=top>Object of type <tt>X</tt></TD></TR><TR><TD VAlign=top><tt>T</tt></TD><TD VAlign=top>The value type of <tt>X</tt></TD></tr></table><h3>Definitions</h3>The <i>size</i> of a container is the number of elements it contains.The size is a nonnegative number.<P>The <i>area</i> of a container is the total number of bytes that itoccupies.  More specifically, it is the sum of the elements' areasplus whatever overhead is associated with the container itself.  If acontainer's value type <tt>T</tt> is a simple type (as opposed to a containertype), then the container's area is bounded above by a constant timesthe container's size times <tt>sizeof(T)</tt>.  That is, if <tt>a</tt> is acontainer with a simple value type, then <tt>a</tt>'s area is <tt>O(a.size())</tt>.<P>A <i>variable sized</i> container is one that provides methods forinserting and/or removing elements; its size may vary during acontainer's lifetime.  A <i>fixed size</i> container is one where the size is constant throughout the container's lifetime.  In somefixed-size container types, the size is determined at compile time.<h3>Valid expressions</h3>In addition to the expressions defined in <A href="Assignable.html">Assignable</A>, <A href="EqualityComparable.html">EqualityComparable</A>, and <A href="LessThanComparable.html">LessThanComparable</A>, the following expressions must be valid.<Table border><TR><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></TR><TR><TD VAlign=top>Beginning of range</TD><TD VAlign=top><tt>a.begin()</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top><tt>iterator</tt> if <tt>a</tt> is mutable, <tt>const_iterator</tt> otherwise <A href="#4">[4]</A> <A href="#7">[7]</A></TD></TR><TR><TD VAlign=top>End of range</TD><TD VAlign=top><tt>a.end()</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top><tt>iterator</tt> if <tt>a</tt> is mutable, <tt>const_iterator</tt> otherwise <A href="#4">[4]</A></TD></TR><TR><TD VAlign=top>Size</TD><TD VAlign=top><tt>a.size()</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top><tt>size_type</tt></TD></TR><TR><TD VAlign=top>Maximum size</TD><TD VAlign=top><tt>a.max_size()</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top><tt>size_type</tt></TD></TR><TR><TD VAlign=top>Empty container</TD><TD VAlign=top><tt>a.empty()</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top>Convertible to <tt>bool</tt></TD></TR><TR><TD VAlign=top>Swap</TD><TD VAlign=top><tt>a.swap(b)</tt></TD><TD VAlign=top>&nbsp;</TD><TD VAlign=top><tt>void</tt></TD></tr></table><h3>Expression semantics</h3>Semantics of an expression is defined only where it differs from, or is not defined in,<A href="Assignable.html">Assignable</A>, <A href="EqualityComparable.html">Equality Comparable</A>,or <A href="LessThanComparable.html">LessThan Comparable</A><Table border><TR><TH>Name</TH>

⌨️ 快捷键说明

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