Computer Algorithms II Lecture Notes

4 September 2008 • Dynamic Storage and C++


Outline

Dynamic Storage

The STL and Other Libraries

  • The other possibility is to use dynamic storage.

    Dynamic Storage and Classes

  • Dynamic storage and classes are not a match made in heaven

    Compile-Time Allocation

    Compile-Time Problems

    Example

    Class and Pointers

    Destructors and Pointers

    Classes and Pointers II

    Class Instance Copying

    The Copy Constructor

    Copying Data

    Classes and Pointers III

    Class Instance Assignment

    Assignments

    The Assignment Operator

    assignment storage management

    Assignment Fine Points

    Self Assignment

    The Self-Assignment Problem

    Handling Self-Assignment

    Assignments as Expressions

    Assignment Prototype

    Seeming Assignments

    Assignment vs. Copying

    Assigning and Copying

    The Rule of Three

    Observations

    Extended Example

    Binary Trees

    Implementation

    But Wait!

    Some Excuses

    Validate Assumptions

    Example

    Problem Solved?

    Node Management

    Example

    Storage Management

    Free Nodes

    Free Fields

    Free Lists

    Free-List Management

    Tree Size

    Template Tree Size

    Dynamic Storage

    Dynamic-Storage Management

    Dynamic Storage Costs

    Avoiding Redundant Work

    Amortizing Costs

    Amortizing Dynamic Storage

    Block Allocation

    Does It?

    Summary


    This page last modified on 4 September 2008.

    Creative
    Commons License