473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sequence

21
Please explain the concept of sequence to me . I know that sequence uses both the concept of Position of List and rank of Vector(source:cpp.datastructure.net)but how does we implement it ? Sequence simply looks like an array - it's so confusing.
Jul 19 '07 #1
2 1267
A Sequence is an ADT that models, well a sequence of something. If you imagine a line of people holding hands you would have a "sequence" of people.

If you further imagine the line grows from left to right then you can imagine two things. First, every person has a number which is how many places they are from the left (this is their rank). Second, everyone has someone (or the end of the sequence) to the left and to the right so relative to them they have a "position" in the sequence such as "I am to the left of Joe and the right of Mary"

That is all there is to it conceptually.

Now, if you implement a sequence with an array it is easy to think of the "rank" and if you implement with a linked list it is easier to think of the "position". But the Sequence ADT, which is what you are asking about, doesn't worry about the implementation details so it is not limited by the ease of implementation.

A properly implemented Seqeunce will have bridging methods anyway which allows the user to use either rank or position.
Jul 19 '07 #2
ravenspoint
111 100+
For an abstract description, that was pretty clear.

Time for some nuts and bolts!

Let's use an STL vector for this.

The rank would simply use the [] operator.

The sequence ( left or right ) would take an iterator and return an iterator for the member on the left or right, or end() if there is none. Something like this:
Expand|Select|Wrap|Line Numbers
  1.     typedef vector < T >::iterator P;
  2.     vector < T > mySequence;
  3.  
  4.     P left( P p ) { if( p == mySequence.begin() ) return mySequence.end(); else return p - 1; }
  5.  
Jul 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kevin | last post by:
Is that even possible? I am creating a web service in .NET to expose some already created .NET programs to other groups. One group is writing the client in PERL, and thus wishes the wsdl schema...
14
by: pat270881 | last post by:
hello, I have to implement a sequence class, however the header file is predefined class sequence { public: // TYPEDEFS and MEMBER CONSTANTS
6
by: Defcon2030 | last post by:
<bHey, can someone help me with this? I've been working on it for a few days now, and my head's starting to spin... </b> // FILE:ex1_imp.cxx // // // // CLASS IMPLEMENTED: sequence (see ex1.h...
1
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the...
5
by: Anan18 | last post by:
Hello sir, I'm supposed to Implement and Test the sequence Class Using a Fixed-Sized Array (Chapter 3), from Data Structures & Other objects using c++. The header file is provided, and so is a test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.