@@ -521,7 +521,7 @@ class my_deque {
521
521
// ------------
522
522
523
523
/* *
524
- * <your documentation>
524
+ *
525
525
*/
526
526
explicit my_deque (const allocator_type& a = allocator_type()):_a(a) {
527
527
const_reference v = value_type ();
@@ -544,17 +544,7 @@ class my_deque {
544
544
assert (valid ());}
545
545
546
546
/* *
547
- * <your documentation>
548
- * allocator_type _a; // allocator for inner arrays
549
- B _b; //allocator for outer array?
550
- b_pointer _top; //points to first container
551
- pointer _e; //end of size
552
- pointer _b; // begining
553
- //pointer_l; //for capacity of current
554
- difference_type _top_size;
555
- difference_type offset;
556
- size_type size;
557
-
547
+ *
558
548
*/
559
549
explicit my_deque (size_type s, const_reference v = value_type(), const allocator_type& a = allocator_type()): _a(a) {
560
550
_top = _outter.allocate ((s/AWIDTH + 1 )*2 );
@@ -587,6 +577,7 @@ class my_deque {
587
577
588
578
/* *
589
579
* Copy Constructor
580
+ *
590
581
*/
591
582
my_deque (const my_deque& that):_a(that._a) {
592
583
_top = _outter.allocate (that._top_size );
@@ -607,7 +598,7 @@ class my_deque {
607
598
// ----------
608
599
609
600
/* *
610
- * <your documentation>
601
+ * deque constructor
611
602
*/
612
603
~my_deque () {
613
604
// call _a.destroy(); and then deallocate each array, then deallocate outside array
@@ -622,7 +613,8 @@ class my_deque {
622
613
// ----------
623
614
624
615
/* *
625
- * <your documentation>
616
+ * @ret my_deque&
617
+ * sets this to the deque passed in
626
618
*/
627
619
my_deque& operator = (const my_deque& rhs) {
628
620
clear ();
@@ -642,7 +634,8 @@ class my_deque {
642
634
// -----------
643
635
644
636
/* *
645
- * <your documentation>
637
+ * @param size_type index, used to index into the deque
638
+ * @ret returns a reference of the object at the location index
646
639
*/
647
640
reference operator [] (size_type index) {
648
641
// dummy is just to be able to compile the skeleton, remove it
@@ -664,7 +657,8 @@ class my_deque {
664
657
return dummy;}
665
658
666
659
/* *
667
- * <your documentation>
660
+ * @param size_type index, used to index into the deque
661
+ * @ret returns a reference of the object at the location index
668
662
*/
669
663
const_reference operator [] (size_type index) const {
670
664
return const_cast <my_deque*>(this )->operator [](index );}
@@ -674,15 +668,17 @@ class my_deque {
674
668
// --
675
669
676
670
/* *
677
- * <your documentation>
671
+ *@param size_type index, used to index into the deque
672
+ * @ret returns a reference of the object at the location index
678
673
*/
679
674
reference at (size_type index) {
680
675
//
681
676
// dummy is just to be able to compile the skeleton, remove it
682
677
return this ->operator [](index );}
683
678
684
679
/* *
685
- * <your documentation>
680
+ * @param size_type index, used to index into the deque
681
+ * @ret returns a reference of the object at the location index
686
682
*/
687
683
const_reference at (size_type index) const {
688
684
return const_cast <my_deque*>(this )->at (index );}
@@ -692,14 +688,14 @@ class my_deque {
692
688
// ----
693
689
694
690
/* *
695
- * <your documentation>
691
+ * @ret object at the end of the array
696
692
*/
697
693
reference back () {
698
694
// dummy is just to be able to compile the skeleton, remove it
699
695
return *(--end ());}
700
696
701
697
/* *
702
- * <your documentation>
698
+ * @ret object at the end of the array
703
699
*/
704
700
const_reference back () const {
705
701
return const_cast <my_deque*>(this )->back ();}
@@ -709,13 +705,13 @@ class my_deque {
709
705
// -----
710
706
711
707
/* *
712
- * <your documentation>
708
+ * @ret returns iterator pointing to the first element
713
709
*/
714
710
iterator begin () {
715
711
return iterator (0 , *this );}
716
712
717
713
/* *
718
- * <your documentation>
714
+ * @ret iterator that points to 1 position past the end of the deque
719
715
*/
720
716
const_iterator begin () const {
721
717
return const_iterator (0 , *this );}
@@ -725,7 +721,7 @@ class my_deque {
725
721
// -----
726
722
727
723
/* *
728
- * <your documentation>
724
+ * clears the array
729
725
*/
730
726
void clear () {
731
727
resize (0 );
@@ -736,7 +732,7 @@ class my_deque {
736
732
// -----
737
733
738
734
/* *
739
- * <your documentation>
735
+ * @ret a bool if the deque is empty
740
736
*/
741
737
bool empty () const {
742
738
return !size ();}
@@ -746,13 +742,14 @@ class my_deque {
746
742
// ---
747
743
748
744
/* *
749
- * <your documentation>
745
+ * @ret iterator that points to 1 position past the end of the deque
746
+
750
747
*/
751
748
iterator end () {
752
749
return iterator (_size, *this );}
753
750
754
751
/* *
755
- * <your documentation>
752
+ * @ret const_iterator that points to 1 position past the end of the deque
756
753
*/
757
754
const_iterator end () const {
758
755
return const_iterator (_size, *this );}
@@ -763,7 +760,8 @@ class my_deque {
763
760
764
761
/* *
765
762
* @param iterator iter, points to location to be erased
766
- * result: size()==
763
+ * @ret an iterator pointing to the location that was erased
764
+ * erases the object at iter
767
765
*/
768
766
iterator erase (iterator iter) {
769
767
if (iter==end ())
@@ -785,7 +783,7 @@ class my_deque {
785
783
// -----
786
784
787
785
/* *
788
- * <your documentation>
786
+ * @ret const_reference the object at the front of the array
789
787
*/
790
788
reference front () {
791
789
// <your code>
@@ -794,7 +792,7 @@ class my_deque {
794
792
return dummy;}
795
793
796
794
/* *
797
- * <your documentation>
795
+ * @ret const_reference the object at the front of the array
798
796
*/
799
797
const_reference front () const {
800
798
return const_cast <my_deque*>(this )->front ();}
@@ -804,8 +802,10 @@ class my_deque {
804
802
// ------
805
803
806
804
/* *
807
- * <your documentation>
805
+ * @param iterator iter points to the location to insert
806
+ * @const_reference val value to insert
808
807
* @ret iterator pointing to spot where inserted
808
+ * pushes stuff at the location iter and afterwards backwards 1 and inserts val
809
809
*/
810
810
iterator insert (iterator iter, const_reference val) {
811
811
resize (_size+1 );
@@ -825,14 +825,14 @@ class my_deque {
825
825
// ---
826
826
827
827
/* *
828
- * <your documentation>
828
+ * removes the last element
829
829
*/
830
830
void pop_back () {
831
831
this ->resize (_size-1 );
832
832
assert (valid ());}
833
833
834
834
/* *
835
- * <your documentation>
835
+ * removes the first element
836
836
*/
837
837
void pop_front () {
838
838
if (_offset == AWIDTH-1 ){
@@ -851,14 +851,16 @@ class my_deque {
851
851
// ----
852
852
853
853
/* *
854
- * <your documentation>
854
+ * @param const_reference val
855
+ * pushes val to the bac of the array
855
856
*/
856
857
void push_back (const_reference val) {
857
858
resize (_size+1 , val);
858
859
assert (valid ());}
859
860
860
861
/* *
861
- * <your documentation>
862
+ * @param const_reference val
863
+ * pushes val to the front of the array, deque[0] returns val
862
864
*/
863
865
void push_front (const_reference val) {
864
866
if (_offset == 0 && _b == 0 )
@@ -879,8 +881,9 @@ class my_deque {
879
881
// ------
880
882
881
883
/* *
882
- * User-level, number of objects
883
- * <your documentation>
884
+ * @param size_type s the size to change the deque to
885
+ * @param const_reference v the value to initialize each new spot to
886
+ * resizes the deque, adds/ removes space from the back
884
887
*/
885
888
void resize (size_type s, const_reference v = value_type()) {
886
889
// if longer but within _top_size but if allocated
@@ -939,7 +942,7 @@ class my_deque {
939
942
// ----
940
943
941
944
/* *
942
- * <your documentation>
945
+ * @ret returns the size_type size of this deque
943
946
*/
944
947
size_type size () const {
945
948
// <your code>
@@ -950,7 +953,8 @@ class my_deque {
950
953
// ----
951
954
952
955
/* *
953
- * <your documentation>
956
+ * @param my_deque&
957
+ * changes all of the containers and info from this deque into the one passed in
954
958
*/
955
959
void swap (my_deque& that) {
956
960
std::swap (this ->_a , that._a ); // allocator for inner arrays
0 commit comments