subject

namespace main_savitch_3{ // CONSTRUCTOR sequence::sequence() { counting = 0; occupied = 0; } // MODIFICATION MEMBER FUNCTIONS// void start( )// Postcondition: The first item on the sequence becomes the current item// (but if the sequence is empty, then there is no current item). void sequence::start() { counting = 0; }// void advance( )// Precondition: is_item returns true.// Postcondition: If the current item was already the last item in the// sequence, then there is no longer any current item. Otherwise, the new// current item is the item immediately after the original current item. void sequence::advance() { assert(is_item()==true); if(occupied==counting) { arr[counting]=0; counting++; } else { arr[counting]=arr[counting+1]; counting++; } }// void insert(const value_type& entry)// Precondition: size( ) < CAPACITY.// Postcondition: A new copy of entry has been inserted in the sequence// before the current item. If there was no current item, then the new entry// has been inserted at the front of the sequence. In either case, the newly// inserted item is now the current item of the sequence. void sequence::insert(const value_type& entry) { assert (size()< CAPACITY); if (is_item() == false){ counting=0;} for (int i= occupied; i>counting;i--) { arr[i] = arr [i-1]; } arr[counting]= entry; occupied++; }// void attach(const value_type& entry)// Precondition: size( ) < CAPACITY.// Postcondition: A new copy of entry has been inserted in the sequence after// the current item. If there was no current item, then the new entry has// been attached to the end of the sequence. In either case, the newly// inserted item is now the current item of the sequence. void sequence::attach(const value_type& entry) { assert (size()< CAPACITY); if (is_item() == false){ arr[occupied-1]= entry;} for (int i= occupied; i> counting; i--) { arr[i]= arr[i+1]; } arr[counting]= entry; occupied++; }// void remove_current( )// Precondition: is_item returns true.// Postcondition: The current item has been removed from the sequence, and //the item after this (if there is one) is now the new current item. void sequence::remove_current() { assert(is_item()== true); for (int i= counting + 1; i< occupied - 1; i++) { arr [i]= arr[i+1]; occupied--; } } // CONSTANT MEMBER FUNCTIONS// size_type size( ) const// Postcondition: The return value is the number of items in the sequence. sequence::size_type sequence::size() const { return occupied; }// bool is_item( ) const// Postcondition: A true return value indicates that there is a valid// "current" item that may be retrieved by activating the current// member function (listed below). A false return value indicates that// there is no valid current item. bool sequence::is_item() const { if (counting < occupied) return true; else return false; }// value_type current( ) const// Precondition: is_item( ) returns true.// Postcondition: The item returned is the current item in the sequence. sequence::value_type sequence::current() const { assert(is_item()==true); return arr[counting]; }}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:30, gerardoblk5931
An atom's diameter is about 0.1 nanometer (1×10-9m), and a human hair is about 1×10-3m. how many times greater is a human hair than an atom's diameter? sorry pushed wronf button but this is math
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, Molly05
In my email i got a message it says a quick message and in message details on who its from its says nicole and under nicole is 50e0bf08e5b671@ualwgypg91wa5wl. uzo9kbud3qjwddygd5.vng -
Answers: 1
image
Computers and Technology, 23.06.2019 02:50, bfell92
There’s only one game mode that stars with the letter ‘e’ in cs: go. which of the options below is it?
Answers: 1
image
Computers and Technology, 23.06.2019 22:50, christingle2004
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
You know the right answer?
namespace main_savitch_3{ // CONSTRUCTOR sequence::sequence() { counting = 0; occupied = 0; } // MOD...

Questions in other subjects:

Konu
Chemistry, 21.04.2020 03:19
Konu
Mathematics, 21.04.2020 03:19