Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/named req/RandomAccessIterator"

From cppreference.com
< cpp‎ | named req
(fmt)
m (Text replace - "{{cpp|" to "{{c|")
Line 16: Line 16:
 
!Expression||Return||Equivalent expression||Notes
 
!Expression||Return||Equivalent expression||Notes
 
|-
 
|-
|{{cpp|i +{{=}} n}}
+
|{{c|i +{{=}} n}}
|{{cpp|It&}}
+
|{{c|It&}}
|{{cpp|while ( n > 0 )
+
|{{c|while ( n > 0 )
 
   ++i;}}
 
   ++i;}}
 
|
 
|
Line 24: Line 24:
 
*Constant complexity
 
*Constant complexity
 
|-
 
|-
|{{cpp|i + n}}
+
|{{c|i + n}}
|{{cpp|It}}
+
|{{c|It}}
|{{cpp|It temp {{=}} i;
+
|{{c|It temp {{=}} i;
 
return i +{{=}} n;}}  
 
return i +{{=}} n;}}  
 
|-
 
|-
|{{cpp|n + i}}||{{cpp|It}}||{{cpp|i + n}}||
+
|{{c|n + i}}||{{c|It}}||{{c|i + n}}||
 
|-
 
|-
|{{cpp|i -{{=}} n}}||{{cpp|It&}}||{{cpp|i +{{=}} -n}}||
+
|{{c|i -{{=}} n}}||{{c|It&}}||{{c|i +{{=}} -n}}||
 
|-
 
|-
|{{cpp|i - n}}||{{cpp|It}}||{{cpp|i + -n}}||
+
|{{c|i - n}}||{{c|It}}||{{c|i + -n}}||
 
|-
 
|-
|{{cpp|n - i}}||{{cpp|It}}||{{cpp|i - n}}||
+
|{{c|n - i}}||{{c|It}}||{{c|i - n}}||
 
|-
 
|-
|{{cpp|a < b}}||{{cpp|bool}}||{{cpp|(a-b) > 0}}
+
|{{c|a < b}}||{{c|bool}}||{{c|(a-b) > 0}}
 
|Strict total ordering relation:
 
|Strict total ordering relation:
 
* {{ttb|!(a < a)}}
 
* {{ttb|!(a < a)}}
Line 44: Line 44:
 
* {{ttb|a < b}} or {{ttb|b < a}} or {{ttb|a {{==}} b}} <br> (exactly one of the expression is true)
 
* {{ttb|a < b}} or {{ttb|b < a}} or {{ttb|a {{==}} b}} <br> (exactly one of the expression is true)
 
|-
 
|-
|{{cpp|a > b}}||{{cpp|bool}}||{{cpp|b < a}}||
+
|{{c|a > b}}||{{c|bool}}||{{c|b < a}}||
 
|-
 
|-
|{{cpp|a >{{=}} b}}||{{cpp|bool}}||{{cpp|!(a < b)}} ||
+
|{{c|a >{{=}} b}}||{{c|bool}}||{{c|!(a < b)}} ||
 
|-
 
|-
|{{cpp|a <{{=}} b}}||{{cpp|bool}}||{{cpp|!(a > b)}}||
+
|{{c|a <{{=}} b}}||{{c|bool}}||{{c|!(a > b)}}||
 
|}
 
|}
 
====Table Notes====
 
====Table Notes====

Revision as of 18:53, 19 April 2012

Template:cpp/concept/title Template:cpp/concept/sidebar

An Iterator that can be moved to point to any element in constant time.

A standard pointer satisfies this concept.

Requirements


Expression Return Equivalent expression Notes
i += n It& while ( n > 0 )

   ++i;

  • n can b both positive or negative
  • Constant complexity
i + n It It temp = i;

return i += n;

n + i It i + n
i -= n It& i += -n
i - n It i + -n
n - i It i - n
a < b bool (a-b) > 0 Strict total ordering relation:
  • !(a < a)
  • if a < b then !(b < a)
  • if a < b and b < c then a < c
  • a < b or b < a or a == b
    (exactly one of the expression is true)
a > b bool b < a
a >= b bool !(a < b)
a <= b bool !(a > b)

Table Notes

  • It is the type implementing this concept
  • i, a, b are objects of type It
  • n is an integer of type difference_type