Tải bản đầy đủ (.pdf) (10 trang)

Lecture Data structures and other objects using C++ - Chapter 3: Container classes - Trường Đại học Công nghiệp Thực phẩm Tp. Hồ Chí Minh

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (546.74 KB, 10 trang )

<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>



</div>
<span class='text_page_counter'>(2)</span><div class='page_container' data-page=2>

Bags



For the first example, 


For the first example, 


think about a bag.


</div>
<span class='text_page_counter'>(3)</span><div class='page_container' data-page=3>

Bags



For the first example, 


For the first example, 


think about a bag.


think about a bag.


Inside the bag are 


Inside the bag are 


some numbers.


</div>
<span class='text_page_counter'>(4)</span><div class='page_container' data-page=4>

Initial State of a Bag



When you first begin 


When you first begin 



to use a bag, the bag 


to use a bag, the bag 


will be empty.


will be empty.


We count on this to be 


We count on this to be 


the 


the initial state<sub>initial state</sub> of any  of any 
bag that we use.


bag that we use.


</div>
<span class='text_page_counter'>(5)</span><div class='page_container' data-page=5>

Inserting Numbers into a Bag



Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.



<i>I AM</i>


<i>PUTTING THE</i>
<i>NUMBER 4</i>


</div>
<span class='text_page_counter'>(6)</span><div class='page_container' data-page=6>

Inserting Numbers into a Bag



Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.


<i>THE 4 IS</i>
<i>IN THE</i>


</div>
<span class='text_page_counter'>(7)</span><div class='page_container' data-page=7>

Inserting Numbers into a Bag



Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.


The bag can hold 



The bag can hold 


many numbers.


many numbers.


<i>NOW  I'M</i>
<i>PUTTING</i>
<i>ANOTHER</i>
<i>NUMBER IN </i>


</div>
<span class='text_page_counter'>(8)</span><div class='page_container' data-page=8>

Inserting Numbers into a Bag



Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.


The bag can hold 


The bag can hold 


many numbers.


many numbers.


</div>
<span class='text_page_counter'>(9)</span><div class='page_container' data-page=9>

Inserting Numbers into a Bag




Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.


The bag can hold 


The bag can hold 


many numbers.


many numbers.


We can even insert 


We can even insert 


the same number 


the same number 


more than once.


more than once. <i><sub>NOW  I'M</sub></i>


<i>PUTTING A</i>


<i>SECOND 4 </i>


</div>
<span class='text_page_counter'>(10)</span><div class='page_container' data-page=10>

Inserting Numbers into a Bag



Numbers may be 


Numbers may be 


inserted into a bag.


inserted into a bag.


The bag can hold 


The bag can hold 


many numbers.


many numbers.


We can even insert 


We can even insert 


the same number 


the same number 


more than once.



</div>

<!--links-->

×