473,785 Members | 2,794 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ring iterator adaptor for vector interator

Suppose I want a ring_iterator, which is almost like the
vector::iterato r. But it will equals begin(), when it passed the end().
It is easy to write an adaptor for it. But I'm wondering if there is
any publicly available code for it.

Thanks,
Peng

Apr 2 '06 #1
3 1959
In article <11************ **********@z34g 2000cwc.googleg roups.com>,
"Pe*******@gmai l.com" <Pe*******@gmai l.com> wrote:
Suppose I want a ring_iterator, which is almost like the
vector::iterato r. But it will equals begin(), when it passed the end().
It is easy to write an adaptor for it. But I'm wondering if there is
any publicly available code for it.


Do you want begin() == end() + 1, or do you want begin() == end()?
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Apr 2 '06 #2

Daniel T. wrote:
In article <11************ **********@z34g 2000cwc.googleg roups.com>,
"Pe*******@gmai l.com" <Pe*******@gmai l.com> wrote:
Suppose I want a ring_iterator, which is almost like the
vector::iterato r. But it will equals begin(), when it passed the end().
It is easy to write an adaptor for it. But I'm wondering if there is
any publicly available code for it.


Do you want begin() == end() + 1, or do you want begin() == end()?


Sorry for the confusion. I want begin() == end().

Apr 2 '06 #3
Pe*******@gmail .com wrote:
Daniel T. wrote:
In article <11************ **********@z34g 2000cwc.googleg roups.com>,
"Pe*******@gmai l.com" <Pe*******@gmai l.com> wrote:
Suppose I want a ring_iterator, which is almost like the
vector::iterato r. But it will equals begin(), when it passed the end().
It is easy to write an adaptor for it. But I'm wondering if there is
any publicly available code for it.

Do you want begin() == end() + 1, or do you want begin() == end()?


Sorry for the confusion. I want begin() == end().


Not a good idea. No standard algorithms will work in that case.

for (T::iterator iter = c.begin();
iter != c.end();
++iter)
{
// yada yada yada
}

Will not execute any loop iterations.
Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2269
by: Stanislaw Salik | last post by:
Hi, Lets suppose we want to use generic algotithms on collections of pointers (both raw and smart). For example, we want to sort a vector of (smart)pointers. We need a comparator that will take two pointers and return a bool. std::vector<std::string *> v; std::sort(v.begin(), v.end(), std::less<int>());
17
3361
by: Michael Hopkins | last post by:
Hi all I want to create a std::vector that goes from 1 to n instead of 0 to n-1. The only change this will have is in loops and when the vector returns positions of elements etc. I am calling this uovec at the moment (for Unit-Offset VECtor). I want the class to respond correctly to all usage of STL containers and algorithms so that it is a transparent replacement for std:vector. The options seems to be:
3
2926
by: codefixer | last post by:
Hello, I am trying to understand if ITERATORS are tied to CONTAINERS. I know the difference between 5 different or 6(Trivial, on SGI). But what I fail to understand is how can I declare all 5 kinds of iterators on say a vector. OR is it that any iterator declared on Vector is Random Iterator which has the functionality of all the others.
5
2938
by: cayblood | last post by:
Hello, I have a vector of pointers to a class, like so: vector<Node*> m_parents; I'm having trouble creating an iterator to go through the elements in this vector. Here is my syntax: vector<Node*>::iterator iter = m_parents.begin();
9
5214
by: Amadeus W. M. | last post by:
I have a vector from which I want to erase elements between iterators i,j. If i<j, everything works as expected, but if j>i, an insertion is actually performed. Example: vector<double> x(10); vector<double>::iterator i=x.begin()+2, j=x.begin()+6; x.erase(i,j); // i<j, ok, erases 4 elements. x.erase(j,i); // j>i, no error, just inserts 4 elements.
4
5709
by: arnuld | last post by:
i wrote a programme to create a vector of 5 elements (0 to 4), here is the code & output: #include <iostream> #include <vector> int main() { std::vector<intivec; // dynamically create a vector
9
2246
by: t | last post by:
Can you use a plain iterator to vector<const intto write to it? It doesn't seem like it should be possible, but Visual C++ 2005 Express lets me: vector<const intvc; vc.push_back(5); vector<const int>::iterator iter = vc.begin(); *iter = 3; // compiles
3
1882
by: subramanian100in | last post by:
Consider vector<stringv; If we call, v.erase(v.end()) this invokes undefined behaviour. But, if we call
5
2073
by: Kenneth Porter | last post by:
Is there a stylistically preferred way to apply an algorithm to a vector of vectors? For example, suppose I have: typedef vector< vector<int Array2D; Array2D array2D; I want to find the top-level element who's 2nd element is the maximum (think searching on column 2). The obvious algorithm is max_element, but do
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.