Skip to content

Instantly share code, notes, and snippets.

@bretth18
Last active December 3, 2016 05:43
Show Gist options
  • Save bretth18/8cf1267394fd851bb64d46d6e964a330 to your computer and use it in GitHub Desktop.
Save bretth18/8cf1267394fd851bb64d46d6e964a330 to your computer and use it in GitHub Desktop.
linked lists
Running tests for sequence Class with a linked sequence
START OF TEST 4:
Testing the copy constructor (2 points).
Copy constructor test: for an empty sequence.
COPIED SEQUENCE: SIZE: 0
ATTACH COND 1
SEQUENCE: 1
HEADPTR: 1
TAILPTR: 1
CURSOR: 1
SIZE: 1
Testing that size() returns 0 ... Passed.
Testing that is_item() returns false ... Passed.
I'll call start() and look at the items one more time...
All tests passed for this sequence.
Copy constructor test: for a sequence with cursor at tail.
ATTACH COND 3
SEQUENCE: 1 2
HEADPTR: 1
PRECURSOR: 1
TAILPTR: 2
CURSOR: 2
SIZE: 2
ATTACH COND 3
SEQUENCE: 1 2 3
HEADPTR: 1
PRECURSOR: 2
TAILPTR: 3
CURSOR: 3
SIZE: 3
ATTACH COND 3
SEQUENCE: 1 2 3 4
HEADPTR: 1
PRECURSOR: 3
TAILPTR: 4
CURSOR: 4
SIZE: 4
ATTACH COND 3
SEQUENCE: 1 2 3 4 5
HEADPTR: 1
PRECURSOR: 4
TAILPTR: 5
CURSOR: 5
SIZE: 5
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6
HEADPTR: 1
PRECURSOR: 5
TAILPTR: 6
CURSOR: 6
SIZE: 6
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7
HEADPTR: 1
PRECURSOR: 6
TAILPTR: 7
CURSOR: 7
SIZE: 7
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8
HEADPTR: 1
PRECURSOR: 7
TAILPTR: 8
CURSOR: 8
SIZE: 8
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9
HEADPTR: 1
PRECURSOR: 8
TAILPTR: 9
CURSOR: 9
SIZE: 9
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10
HEADPTR: 1
PRECURSOR: 9
TAILPTR: 10
CURSOR: 10
SIZE: 10
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11
HEADPTR: 1
PRECURSOR: 10
TAILPTR: 11
CURSOR: 11
SIZE: 11
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12
HEADPTR: 1
PRECURSOR: 11
TAILPTR: 12
CURSOR: 12
SIZE: 12
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13
HEADPTR: 1
PRECURSOR: 12
TAILPTR: 13
CURSOR: 13
SIZE: 13
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
HEADPTR: 1
PRECURSOR: 13
TAILPTR: 14
CURSOR: 14
SIZE: 14
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HEADPTR: 1
PRECURSOR: 14
TAILPTR: 15
CURSOR: 15
SIZE: 15
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
HEADPTR: 1
PRECURSOR: 15
TAILPTR: 16
CURSOR: 16
SIZE: 16
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
HEADPTR: 1
PRECURSOR: 16
TAILPTR: 17
CURSOR: 17
SIZE: 17
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
HEADPTR: 1
PRECURSOR: 17
TAILPTR: 18
CURSOR: 18
SIZE: 18
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
HEADPTR: 1
PRECURSOR: 18
TAILPTR: 19
CURSOR: 19
SIZE: 19
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
HEADPTR: 1
PRECURSOR: 19
TAILPTR: 20
CURSOR: 20
SIZE: 20
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
HEADPTR: 1
PRECURSOR: 20
TAILPTR: 21
CURSOR: 21
SIZE: 21
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
HEADPTR: 1
PRECURSOR: 21
TAILPTR: 22
CURSOR: 22
SIZE: 22
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
HEADPTR: 1
PRECURSOR: 22
TAILPTR: 23
CURSOR: 23
SIZE: 23
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
HEADPTR: 1
PRECURSOR: 23
TAILPTR: 24
CURSOR: 24
SIZE: 24
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
HEADPTR: 1
PRECURSOR: 24
TAILPTR: 25
CURSOR: 25
SIZE: 25
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
HEADPTR: 1
PRECURSOR: 25
TAILPTR: 26
CURSOR: 26
SIZE: 26
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
HEADPTR: 1
PRECURSOR: 26
TAILPTR: 27
CURSOR: 27
SIZE: 27
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
HEADPTR: 1
PRECURSOR: 27
TAILPTR: 28
CURSOR: 28
SIZE: 28
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
HEADPTR: 1
PRECURSOR: 28
TAILPTR: 29
CURSOR: 29
SIZE: 29
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
HEADPTR: 1
PRECURSOR: 29
TAILPTR: 30
CURSOR: 30
SIZE: 30
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
HEADPTR: 1
PRECURSOR: 30
TAILPTR: 31
CURSOR: 31
SIZE: 31
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
HEADPTR: 1
PRECURSOR: 31
TAILPTR: 32
CURSOR: 32
SIZE: 32
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
HEADPTR: 1
PRECURSOR: 32
TAILPTR: 33
CURSOR: 33
SIZE: 33
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
HEADPTR: 1
PRECURSOR: 33
TAILPTR: 34
CURSOR: 34
SIZE: 34
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
HEADPTR: 1
PRECURSOR: 34
TAILPTR: 35
CURSOR: 35
SIZE: 35
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
HEADPTR: 1
PRECURSOR: 35
TAILPTR: 36
CURSOR: 36
SIZE: 36
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
HEADPTR: 1
PRECURSOR: 36
TAILPTR: 37
CURSOR: 37
SIZE: 37
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
HEADPTR: 1
PRECURSOR: 37
TAILPTR: 38
CURSOR: 38
SIZE: 38
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
HEADPTR: 1
PRECURSOR: 38
TAILPTR: 39
CURSOR: 39
SIZE: 39
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
HEADPTR: 1
PRECURSOR: 39
TAILPTR: 40
CURSOR: 40
SIZE: 40
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
HEADPTR: 1
PRECURSOR: 40
TAILPTR: 41
CURSOR: 41
SIZE: 41
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
HEADPTR: 1
PRECURSOR: 41
TAILPTR: 42
CURSOR: 42
SIZE: 42
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
HEADPTR: 1
PRECURSOR: 42
TAILPTR: 43
CURSOR: 43
SIZE: 43
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
HEADPTR: 1
PRECURSOR: 43
TAILPTR: 44
CURSOR: 44
SIZE: 44
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
HEADPTR: 1
PRECURSOR: 44
TAILPTR: 45
CURSOR: 45
SIZE: 45
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
HEADPTR: 1
PRECURSOR: 45
TAILPTR: 46
CURSOR: 46
SIZE: 46
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
HEADPTR: 1
PRECURSOR: 46
TAILPTR: 47
CURSOR: 47
SIZE: 47
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
HEADPTR: 1
PRECURSOR: 47
TAILPTR: 48
CURSOR: 48
SIZE: 48
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
HEADPTR: 1
PRECURSOR: 48
TAILPTR: 49
CURSOR: 49
SIZE: 49
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
HEADPTR: 1
PRECURSOR: 49
TAILPTR: 50
CURSOR: 50
SIZE: 50
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
HEADPTR: 1
PRECURSOR: 50
TAILPTR: 51
CURSOR: 51
SIZE: 51
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
HEADPTR: 1
PRECURSOR: 51
TAILPTR: 52
CURSOR: 52
SIZE: 52
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
HEADPTR: 1
PRECURSOR: 52
TAILPTR: 53
CURSOR: 53
SIZE: 53
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
HEADPTR: 1
PRECURSOR: 53
TAILPTR: 54
CURSOR: 54
SIZE: 54
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
HEADPTR: 1
PRECURSOR: 54
TAILPTR: 55
CURSOR: 55
SIZE: 55
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
HEADPTR: 1
PRECURSOR: 55
TAILPTR: 56
CURSOR: 56
SIZE: 56
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
HEADPTR: 1
PRECURSOR: 56
TAILPTR: 57
CURSOR: 57
SIZE: 57
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
HEADPTR: 1
PRECURSOR: 57
TAILPTR: 58
CURSOR: 58
SIZE: 58
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
HEADPTR: 1
PRECURSOR: 58
TAILPTR: 59
CURSOR: 59
SIZE: 59
ATTACH COND 3
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
HEADPTR: 1
PRECURSOR: 59
TAILPTR: 60
CURSOR: 60
SIZE: 60
COPIED SEQUENCE: 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
HEADPTR: 1
PRECURSOR: 59
TAILPTR: 60
CURSOR: 60
SIZE: 60
touched here
SEQUENCE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
HEADPTR: 1
PRECURSOR: 59
TAILPTR: 59
SIZE: 59
SEQUENCE: 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
HEADPTR: 1
PRECURSOR: 1
TAILPTR: 59
CURSOR: 3
SIZE: 58
Testing that size() returns 60 ... Passed.
Testing that is_item() returns true ... Passed.
The cursor should be at item [59] of the sequence
(counting the first item as [0]). I will advance the cursor
to the end of the sequence, checking that each item is correct...
The item [59] should be 60,
but it was 0 instead.
Failed.
Test of the sequence's items failed.
Test 4 failed.
END OF TEST 4.
0
If you submit this sequence to Dora now, you will have
0 points out of the 18 points from this test program.
Program ended with exit code: 0
#include <iostream> // Provides cout.
#include <cstdlib> // Provides size_t.
#include "sequenceClass.h" // Provides the sequence class with double items.
using namespace std;
/****************************************
CHANGE THIS LINE: */
using namespace cs_sequenceClass;
/****************************************/
// Descriptions and points for each of the tests:
const size_t MANY_TESTS = 6;
const int POINTS[MANY_TESTS+1] = {
18, // Total points for all tests.
4, // Test 1 points
4, // Test 2 points
4, // Test 3 points
2, // Test 4 points
2, // Test 5 points
2 // Test 6 points
};
const char DESCRIPTION[MANY_TESTS+1][256] = {
"tests for sequence Class with a linked sequence",
"Testing insert, attach, and the constant member functions",
"Testing situations where the cursor goes off the sequence",
"Testing remove_current",
"Testing the copy constructor",
"Testing the assignment operator",
"Testing insert/attach for somewhat larger sequences"
};
// **************************************************************************
// bool test_basic(const sequence& test, size_t s, bool has_cursor)
// Postcondition: A return value of true indicates:
// a. test.size() is s, and
// b. test.is_item() is has_cursor.
// Otherwise the return value is false.
// In either case, a description of the test result is printed to cout.
// **************************************************************************
bool test_basic(const sequence& test, size_t s, bool has_cursor)
{
bool answer;
cout << "Testing that size() returns " << s << " ... ";
cout.flush( );
answer = (test.size( ) == s);
cout << (answer ? "Passed." : "Failed.") << endl;
if (answer)
{
cout << "Testing that is_item() returns ";
cout << (has_cursor ? "true" : "false") << " ... ";
cout.flush( );
answer = (test.is_item( ) == has_cursor);
cout << (answer ? "Passed." : "Failed.") << endl;
}
return answer;
}
// **************************************************************************
// bool test_items(sequence& test, size_t s, size_t i, double items[])
// The function determines if the test sequence has the correct items
// Precondition: The size of the items array is at least s.
// Postcondition: A return value of true indicates that test.current()
// is equal to items[i], and after test.advance() the result of
// test.current() is items[i+1], and so on through items[s-1].
// At this point, one more advance takes the cursor off the sequence.
// If any of this fails, the return value is false.
// NOTE: The test sequence has been changed by advancing its cursor.
// **************************************************************************
bool test_items(sequence& test, size_t s, size_t i, double items[])
{
bool answer = true;
cout << "The cursor should be at item [" << i << "]" << " of the sequence\n";
cout << "(counting the first item as [0]). I will advance the cursor\n";
cout << "to the end of the sequence, checking that each item is correct...";
cout.flush( );
while ((i < s) && test.is_item( ) && (test.current( ) == items[i]))
{
i++;
/* DEBUG */
std::cout<< "CURS: " << test.current() << std::endl;
test.advance( );
}
if ((i != s) && !test.is_item( ))
{ // The test.is_item( ) function returns false too soon.
cout << "\n Cursor fell off the sequence too soon." << endl;
answer = false;
}
else if (i != s)
{ // The test.current( ) function returned a wrong value.
cout << "\n The item [" << i << "] should be " << items[i] << ",\n";
cout << " but it was " << test.current( ) << " instead.\n";
answer = false;
}
else if (test.is_item( ))
{ // The test.is_item( ) function returns true after moving off the sequence.
cout << "\n The cursor was moved off the sequence,";
cout << " but is_item still returns true." << endl;
answer = false;
}
cout << (answer ? "Passed." : "Failed.") << endl;
return answer;
}
// **************************************************************************
// bool correct(sequence& test, size_t s, size_t cursor_spot, double items[])
// This function determines if the sequence (test) is "correct" according to
// these requirements:
// a. it has exactly s items.
// b. the items (starting at the front) are equal to
// items[0] ... items[s-1]
// c. if cursor_spot < s, then test's cursor must be at
// the location given by cursor_spot.
// d. if cursor_spot >= s, then test must not have a cursor.
// NOTE: The function also moves the cursor off the sequence.
// **************************************************************************
bool correct(sequence& test, size_t size, size_t cursor_spot, double items[])
{
bool has_cursor = (cursor_spot < size);
// Check the sequence's size and whether it has a cursor.
if (!test_basic(test, size, has_cursor))
{
cout << "Basic test of size() or is_item() failed." << endl << endl;
return false;
}
// If there is a cursor, check the items from cursor to end of the sequence.
if (has_cursor && !test_items(test, size, cursor_spot, items))
{
cout << "Test of the sequence's items failed." << endl << endl;
return false;
}
// Restart the cursor at the front of the sequence and test items again.
cout << "I'll call start() and look at the items one more time..." << endl;
test.start( );
if (has_cursor && !test_items(test, size, 0, items))
{
cout << "Test of the sequence's items failed." << endl << endl;
return false;
}
// If the code reaches here, then all tests have been passed.
cout << "All tests passed for this sequence." << endl << endl;
return true;
}
// **************************************************************************
// int test1( )
// Performs some basic tests of insert, attach, and the constant member
// functions. Returns POINTS[1] if the tests are passed. Otherwise returns 0.
// **************************************************************************
int test1( )
{
sequence empty; // An empty sequence
sequence test; // A sequence to add items to
double items1[4] = { 5, 10, 20, 30 }; // These 4 items are put in a sequence
double items2[4] = { 10, 15, 20, 30 }; // These are put in another sequence
// Test that the empty sequence is really empty
cout << "Starting with an empty sequence." << endl;
if (!correct(empty, 0, 0, items1)) return 0;
// Test the attach function to add something to an empty sequence
cout << "I am now using attach to put 10 into an empty sequence." << endl;
test.attach(10);
if (!correct(test, 1, 0, items2)) return 0;
// Test the insert function to add something to an empty sequence
cout << "I am now using insert to put 10 into an empty sequence." << endl;
test = empty;
test.insert(10);
if (!correct(test, 1, 0, items2)) return 0;
// Test the insert function to add an item at the front of a sequence
cout << "I am now using attach to put 10,20,30 in an empty sequence.\n";
cout << "Then I move the cursor to the start and insert 5." << endl;
test = empty;
test.attach(10);
test.attach(20);
test.attach(30);
test.start( );
test.insert(5);
if (!correct(test, 4, 0, items1)) return 0;
// Test the insert function to add an item in the middle of a sequence
cout << "I am now using attach to put 10,20,30 in an empty sequence.\n";
cout << "Then I move the cursor to the start, advance once, ";
cout << "and insert 15." << endl;
test = empty;
test.attach(10);
test.attach(20);
test.attach(30);
test.start( );
test.advance( );
test.insert(15);
if (!correct(test, 4, 1, items2)) return 0;
// Test the attach function to add an item in the middle of a sequence
cout << "I am now using attach to put 10,20,30 in an empty sequence.\n";
cout << "Then I move the cursor to the start and attach 15 ";
cout << "after the 10." << endl;
test = empty;
test.attach(10);
test.attach(20);
test.attach(30);
test.start( );
test.attach(15);
if (!correct(test, 4, 1, items2)) return 0;
// All tests have been passed
cout << "All tests of this first function have been passed." << endl;
return POINTS[1];
}
// **************************************************************************
// int test2( )
// Performs a test to ensure that the cursor can correctly be run off the end
// of the sequence. Also tests that attach/insert work correctly when there is
// no cursor. Returns POINTS[2] if the tests are passed. Otherwise returns 0.
// **************************************************************************
int test2( )
{
const size_t TESTSIZE = 30;
sequence test;
size_t i;
// Put three items in the sequence
cout << "Using attach to put 20 and 30 in the sequence, and then calling\n";
cout << "advance, so that is_item should return false ... ";
cout.flush( );
test.attach(20);
test.attach(30);
test.advance( );
if (test.is_item( ))
{
cout << "failed." << endl;
return 0;
}
cout << "passed." << endl;
// Insert 10 at the front and run the cursor off the end again
cout << "Inserting 10, which should go at the sequence's front." << endl;
cout << "Then calling advance three times to run cursor off the sequence ...";
cout.flush( );
test.insert(10);
test.advance( ); // advance to the 20
test.advance( ); // advance to the 30
test.advance( ); // advance right off the sequence
if (test.is_item( ))
{
cout << " failed." << endl;
return false;
}
cout << " passed." << endl;
// Attach more items until the sequence becomes full.
// Note that the first attach should attach to the end of the sequence.
cout << "Calling attach to put the numbers 40, 50, 60 ...";
cout << TESTSIZE*10 << " at the sequence's end." << endl;
for (i = 4; i <= TESTSIZE; i++)
test.attach(i*10);
// Test that the sequence is correctly filled.
cout << "Now I will test that the sequence has 10, 20, 30, ...";
cout << TESTSIZE*10 << "." << endl;
test.start( );
for (i = 1; i <= TESTSIZE; i++)
{
if ((!test.is_item( )) || test.current( ) != i*10)
{
cout << " Test failed to find " << i*10 << endl;
return 0;
}
test.advance( );
}
if (test.is_item( ))
{
cout << " There are too many items on the sequence." << endl;
return false;
}
// All tests passed
cout << "All tests of this second function have been passed." << endl;
return POINTS[2];
}
// **************************************************************************
// int test3( )
// Performs basic tests for the remove_current function.
// Returns POINTS[3] if the tests are passed.
// Otherwise returns 0.
// **************************************************************************
int test3( )
{
const size_t TESTSIZE = 30;
sequence test;
// Within this function, I create several different sequences using the
// items in these arrays:
double items1[1] = { 30 };
double items2[2] = { 10, 30 };
double items3[3] = { 10, 20, 30 };
size_t i; // for-loop control variable
// Build a sequence with three items 10, 20, 30, and remove the middle,
// and last and then first.
cout << "Using attach to build a sequence with 10,30." << endl;
test.attach(10);
test.attach(30);
cout << "Insert a 20 before the 30, so entire sequence is 10,20,30." << endl;
test.insert(20);
if (!correct(test, 3, 1, items3)) return 0;
cout << "Remove the 20, so entire sequence is now 10,30." << endl;
test.start( );
test.advance( );
test.remove_current( );
if (!correct(test, 2, 1, items2)) return 0;
cout << "Remove the 30, so entire sequence is now just 10 with no cursor.";
cout << endl;
test.start( );
test.advance( );
test.remove_current( );
if (!correct(test, 1, 1, items2)) return 0;
cout << "Set the cursor to the start and remove the 10." << endl;
test.start( );
test.remove_current( );
if (!correct(test, 0, 0, items2)) return 0;
//test.start();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.is_item() << endl;
// Build a sequence with three items 10, 20, 30, and remove the middle,
// and then first and then last.
cout << "Using attach to build another sequence with 10,30." << endl;
test.attach(10);
//test.start();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.is_item() << endl;
test.attach(30);
//test.start();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.is_item() << endl;
cout << "Insert a 20 before the 30, so entire sequence is 10,20,30." << endl;
test.insert(20);
//test.start();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.current() << " ";
//test.advance();
//cout << test.is_item() << endl;
if (!correct(test, 3, 1, items3)) return 0;
cout << "Remove the 20, so entire sequence is now 10,30." << endl;
test.start( );
test.advance( );
test.remove_current( );
if (!correct(test, 2, 1, items2)) return 0;
cout << "Set the cursor to the start and remove the 10," << endl;
cout << "so the sequence should now contain just 30." << endl;
test.start( );
test.remove_current( );
if (!correct(test, 1, 0, items1)) return 0;
cout << "Remove the 30 from the sequence, resulting in an empty sequence." << endl;
test.start( );
test.remove_current( );
if (!correct(test, 0, 0, items1)) return 0;
// Build a sequence with three items 10, 20, 30, and remove the first.
cout << "Build a new sequence by inserting 30, 10, 20 (so the sequence\n";
cout << "is 20, then 10, then 30). Then remove the 20." << endl;
test.insert(30);
test.insert(10);
test.insert(20);
test.remove_current( );
if (!correct(test, 2, 0, items2)) return 0;
test.start( );
test.remove_current( );
test.remove_current( );
// Just for fun, fill up the sequence, and empty it!
cout << "Just for fun, I'll empty the sequence then fill it up, then\n";
cout << "empty it again. During this process, I'll try to determine\n";
cout << "whether any of the sequence's member functions access the\n";
cout << "array outside of its legal indexes." << endl;
for (i = 0; i < TESTSIZE; i++)
test.insert(0);
for (i = 0; i < TESTSIZE; i++)
test.remove_current( );
// All tests passed
cout << "All tests of this third function have been passed." << endl;
return POINTS[3];
}
// **************************************************************************
// int test4( )
// Performs some tests of the copy constructor.
// Returns POINTS[4] if the tests are passed. Otherwise returns 0.
// **************************************************************************
int test4( )
{
const size_t TESTSIZE = 30;
sequence original; // A sequence that we'll copy.
double items[2*TESTSIZE];
size_t i;
// Set up the items array to conatin 1...2*TESTSIZE.
for (i = 1; i <= 2*TESTSIZE; i++)
items[i-1] = i;
// Test copying of an empty sequence. After the copying, we change original.
cout << "Copy constructor test: for an empty sequence." << endl;
sequence copy1(original);
original.attach(1); // Changes the original sequence, but not the copy.
if (!correct(copy1, 0, 0, items)) return 0;
// Test copying of a sequence with current item at the tail.
cout << "Copy constructor test: for a sequence with cursor at tail." << endl;
for (i=2; i <= 2*TESTSIZE; i++)
original.attach(i);
sequence copy2(original);
original.remove_current( ); // Delete tail from original, but not the copy
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy2, 2*TESTSIZE, 2*TESTSIZE-1, items)
)
return 0;
// Test copying of a sequence with cursor near the middle.
cout << "Copy constructor test: with cursor near middle." << endl;
original.insert(2);
for (i = 1; i < TESTSIZE; i++)
original.advance( );
// Cursor is now at location [TESTSIZE] (counting [0] as the first spot).
sequence copy3(original);
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy3, 2*TESTSIZE-1, TESTSIZE, items)
)
return 0;
// Test copying of a sequence with cursor at the front.
cout << "Copy constructor test: for a sequence with cursor at front." << endl;
original.insert(2);
original.start( );
// Cursor is now at the front.
sequence copy4(original);
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy4, 2*TESTSIZE-1, 0, items)
)
return 0;
// Test copying of a sequence with no current item.
cout << "Copy constructor test: for a sequence with no current item." << endl;
original.insert(2);
while (original.is_item( ))
original.advance( );
// There is now no current item.
sequence copy5(original);
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy5, 2*TESTSIZE-1, 2*TESTSIZE, items)
)
return 0;
// All tests passed
cout << "All tests of this fourth function have been passed." << endl;
return POINTS[4];
}
// **************************************************************************
// int test5( )
// Performs some tests of the assignment operator.
// Returns POINTS[5] if the tests are passed. Otherwise returns 0.
// **************************************************************************
int test5( )
{
const size_t TESTSIZE = 30;
sequence original; // A sequence that we'll copy.
double items[2*TESTSIZE];
size_t i;
// Set up the items array to conatin 1...2*TESTSIZE.
for (i = 1; i <= 2*TESTSIZE; i++)
items[i-1] = i;
// Test copying of an empty sequence. After the copying, we change original.
cout << "Assignment operator test: for an empty sequence." << endl;
sequence copy1;
copy1 = original;
original.attach(1); // Changes the original sequence, but not the copy.
if (!correct(copy1, 0, 0, items)) return 0;
// Test copying of a sequence with current item at the tail.
cout << "Assignment operator test: cursor at tail." << endl;
for (i=2; i <= 2*TESTSIZE; i++)
original.attach(i);
sequence copy2;
copy2 = original;
original.remove_current( ); // Delete tail from original, but not the copy
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy2, 2*TESTSIZE, 2*TESTSIZE-1, items)
)
return 0;
// Test copying of a sequence with cursor near the middle.
cout << "Assignment operator test: with cursor near middle." << endl;
original.insert(2);
for (i = 1; i < TESTSIZE; i++)
original.advance( );
// Cursor is now at location [TESTSIZE] (counting [0] as the first spot).
sequence copy3;
copy3 = original;
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy3, 2*TESTSIZE-1, TESTSIZE, items)
)
return 0;
// Test copying of a sequence with cursor at the front.
cout << "Assignment operator test: with cursor at front." << endl;
original.insert(2);
original.start( );
// Cursor is now at the front.
sequence copy4;
copy4 = original;
original.start( );
original.advance( );
original.remove_current( ); // Delete 2 from original, but not the copy.
if (!correct
(copy4, 2*TESTSIZE-1, 0, items)
)
return 0;
// Test copying of a sequence with no current item.
cout << "Assignment operator test: with no current item." << endl;
original.insert(2);
while (original.is_item( ))
original.advance( );
// There is now no current item.
sequence copy5;
copy5 = original;
original.start( );
original.advance( );
original.remove_current( ); // Deletes 2 from the original, but not copy.
if (!correct
(copy5, 2*TESTSIZE-1, 2*TESTSIZE, items)
)
return 0;
cout << "Checking correctness of a self-assignment x = x;" << endl;
original.insert(2);
original = original;
if (!correct
(original, 2*TESTSIZE-1, 1, items)
)
return 0;
// All tests passed
cout << "All tests of this fifth function have been passed." << endl;
return POINTS[5];
}
// **************************************************************************
// int test6( )
// Performs some basic tests of insert and attach for the case where the
// current capacity has been reached.
// Returns POINTS[6] if the tests are passed. Otherwise returns 0.
// **************************************************************************
int test6( )
{
const size_t TESTSIZE = 30;
sequence testa, testi;
double items[2*TESTSIZE];
size_t i;
// Set up the items array to conatin 1...2*TESTSIZE.
for (i = 1; i <= 2*TESTSIZE; i++)
items[i-1] = i;
cout << "Testing to see that attach works correctly when the\n";
cout << "current capacity is exceeded." << endl;
for (i = 1; i <= 2*TESTSIZE; i++)
testa.attach(i);
if (!correct
(testa, 2*TESTSIZE, 2*TESTSIZE-1, items)
)
return 0;
cout << "Testing to see that insert works correctly when the\n";
cout << "current capacity is exceeded." << endl;
for (i = 2*TESTSIZE; i >= 1; i--)
testi.insert(i);
if (!correct
(testi, 2*TESTSIZE, 0, items)
)
return 0;
// All tests passed
cout << "All tests of this sixth function have been passed." << endl;
return POINTS[6];
}
int run_a_test(int number, const char message[], int test_function( ), int max)
{
int result;
cout << endl << "START OF TEST " << number << ":" << endl;
cout << message << " (" << max << " points)." << endl;
result = test_function( );
if (result > 0)
{
cout << "Test " << number << " got " << result << " points";
cout << " out of a possible " << max << "." << endl;
}
else
cout << "Test " << number << " failed." << endl;
cout << "END OF TEST " << number << "." << endl << endl;
return result;
}
// **************************************************************************
// int main( )
// The main program calls all tests and prints the sum of all points
// earned from the tests.
// **************************************************************************
int main( )
{
int sum = 0;
cout << "Running " << DESCRIPTION[0] << endl;
// sum += run_a_test(1, DESCRIPTION[1], test1, POINTS[1]); cout << sum << endl;
// sum += run_a_test(2, DESCRIPTION[2], test2, POINTS[2]); cout << sum << endl;
// sum += run_a_test(3, DESCRIPTION[3], test3, POINTS[3]); cout << sum << endl;
sum += run_a_test(4, DESCRIPTION[4], test4, POINTS[4]); cout << sum << endl;
// sum += run_a_test(5, DESCRIPTION[5], test5, POINTS[5]); cout << sum << endl;
// sum += run_a_test(6, DESCRIPTION[6], test6, POINTS[6]); cout << sum << endl;
cout << "If you submit this sequence to Dora now, you will have\n";
cout << sum << " points out of the " << POINTS[0];
cout << " points from this test program.\n";
return EXIT_SUCCESS;
}
#include "sequenceClass.h"
namespace cs_sequenceClass {
// constructor
sequence::sequence() {
numItems = 0;
cursor = NULL;
headPtr = NULL;
tailPtr = NULL;
precursor = NULL;
}
// copy constructor
sequence::sequence(const sequence& copy) {
copySequence(copy);
}
// deconstructor
sequence::~sequence() {
deleteSequence();
}
void sequence::deleteSequence() {
// start from top
node* tempcursor = headPtr;
if (tempcursor == NULL) {
return;
}
while(tempcursor != NULL) {
node* garbage = tempcursor;
tempcursor = tempcursor->next;
delete garbage;
}
numItems = 0;
}
void sequence::copySequence(const sequence& inputSeq) {
// temporary pointer has the inputseq header
node* tempptr = inputSeq.headPtr;
node* tempCurptr = inputSeq.cursor;
node* tempPreptr = inputSeq.precursor;
node* tempTailptr = inputSeq.tailPtr;
// if temporary pointer is NULL
if(tempptr==NULL) {
headPtr = new node;
headPtr = tempptr;
cursor = new node;
cursor = tempCurptr;
precursor = new node;
precursor = tempPreptr;
tailPtr = new node;
tailPtr = tempTailptr;
} else {
// create new node
headPtr = new node;
// current pointer point to head
node* curptr = headPtr;
// copy temporary pointer data to current pointer
curptr->data = tempptr->data;
// set next pointer of current pointer to null
curptr->next = NULL;
/* modified*/
// tempptr = tempptr->next;
// numItems++;
// while temporary ponter is not null
while(tempptr!=NULL) {
numItems++;
/*test*/
cursor = new node;
cursor = tempCurptr;
precursor = new node;
precursor = tempPreptr;
tailPtr = new node;
tailPtr = tempTailptr;
// create a new node and assign it tp current ponter
curptr->next=new node;
// Now the current pointer is next pointer
curptr = curptr->next;
// Assign data to the currentpointer
curptr->data = tempptr->data;
// Assign null to next
curptr->next=NULL;
// teemppttr points to next node
tempptr = tempptr->next;
}
}
/*debug*/
std::cout << std::endl;
std::cout << "COPIED ";
debug(*this);
}
void sequence::insert(const value_type& entry) {
numItems++;
node* tempptr = new node;
tempptr -> data = entry;
if (headPtr == NULL) { // inserting into empty list.
tempptr -> next = NULL; // precursor remains NULL.
headPtr = tempptr;
tailPtr = tempptr;
} else if (cursor == NULL || cursor == headPtr) { // inserting at front.
// tailptr and precursor don't change.
tempptr -> next = headPtr;
headPtr = tempptr;
} else { // inserting anywhere else.
tempptr -> next = cursor; // tailptr, headptr and precursor don't change.
precursor -> next = tempptr;
}
cursor = tempptr;
}
void sequence::attach(const value_type& entry) {
numItems++;
node* tempptr = new node;
tempptr -> data = entry;
// empty sequence
if (headPtr == NULL) {
std::cout << "ATTACH COND 1" << std::endl;
tempptr->next = NULL;
headPtr = tempptr;
tailPtr = tempptr;
}
// no current item
else if (cursor == NULL) {
std::cout << "ATTACH COND 2" << std::endl;
// insert @ end
tailPtr->next = tempptr;
tailPtr = tempptr;
} else {
std::cout << "ATTACH COND 3" << std::endl;
// inserted into sequence after current
precursor = cursor;
tempptr->next = cursor->next;
cursor -> next = tempptr;
// if item is the last in the sequence now
if (tailPtr == headPtr || tailPtr == NULL || tailPtr->next != NULL) {
tailPtr = tempptr;
}
}
cursor = tempptr;
debug(*this);
}
sequence::size_type sequence::size() const {
return numItems;
}
void sequence::start() {
// there is nothing in the sequence
if (headPtr == NULL) {
cursor = NULL;
} else {
// set cursor to first item in the sequence
cursor = headPtr;
}
}
void sequence::debug(const sequence& inputSequence) {
node* tempptr = inputSequence.headPtr;
std::cout << "SEQUENCE: ";
while (tempptr != NULL){
std::cout << tempptr->data << " ";
tempptr = tempptr->next;
}
if (inputSequence.headPtr != NULL) {
std::cout << "\n" << "HEADPTR: " << inputSequence.headPtr->data << std::endl;
}
if (inputSequence.precursor != NULL) {
std::cout << "PRECURSOR: " << inputSequence.precursor->data << std::endl;
}
if (inputSequence.tailPtr != NULL) {
std::cout << "TAILPTR: " << inputSequence.tailPtr->data << std::endl;
}
if (inputSequence.cursor != NULL) {
std::cout << "CURSOR: " << inputSequence.cursor->data << std::endl;
}
std::cout << "SIZE: " << size() << std::endl;
std::cout << std::endl;
}
void sequence::advance() {
assert(is_item());
if (cursor == precursor) {
cursor = NULL;
} else {
precursor = cursor;
cursor = cursor->next;
}
}
sequence::value_type sequence::current() const {
// return cursor->data;
if (cursor->data == NULL) {
return NULL;
} else {
return cursor->data;
}
}
bool sequence::is_item() const {
return (cursor != NULL);
}
void sequence::remove_current() {
assert(is_item());
numItems--;
// set to temp
node* tempptr = cursor;
if (tempptr == headPtr) {
headPtr = headPtr->next;
cursor = cursor->next;
} else {
if (cursor == tailPtr) {
std::cout << "touched here" << std::endl;
tailPtr = precursor;
}
precursor->next = cursor->next;
cursor = cursor->next;
}
delete tempptr;
debug(*this);
}
sequence sequence::operator =(const sequence& right) {
if (this != &right) {
// deallocate & copy construct
deleteSequence();
copySequence(right);
}
return *this;
}
}
#ifndef sequenceClass_h
#define sequenceClass_h
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <cassert>
namespace cs_sequenceClass {
class sequence {
typedef int value_type;
typedef std::size_t size_type;
private:
struct node {
value_type data;
node *next;
};
node *headPtr;
node *tailPtr;
node *cursor;
node *precursor;
public:
value_type numItems;
sequence(const sequence& copy);
void debug(const sequence& inputSequence);
// deconstructor
~sequence();
sequence();
// postcondition: The sequence has been initialized to an empty sequence.
// helper function for copy constructor
void copySequence(const sequence& inputSeq);
void start();
// postcondition: The first item in the sequence becomes the current item (but if the
// sequence is empty, then there is no current item).
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 item is the item immediately after
// the original current item.
void insert(const value_type& entry);
// 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. In either case, the new item is now the current item of the sequence.
void attach(const value_type& entry);
// 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 new item is now the current item of the sequence.
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.
size_type size() const;
// Postcondition: Returns the number of items in the sequence.
bool is_item() const;
// Postcondition: A true return value indicates that there is a valid “current” item that
// may be retrieved by the current member function (listed below). A false return value
// indicates that there is no valid current item.
value_type current() const;
// Precondition: is_item() returns true
// Postcondition: The current item in the sequence is returned.
sequence operator =(const sequence& right);
void deleteSequence();
};
}
#endif /* sequenceClass_h */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment