Expand description

The Composite design pattern example module

The Composite pattern is used when a collection of objects is to be formed in a hierarchical form where each object needs to be treated like any other object but some objects can contain other objects.

This example uses a file structure of file and directories to represent each object type.

Accessed through the composite_exercise() function.

Modules

  • Contains the DirEntry struct that represents a directory entry in a hierarchical list.
  • Contains the implementation of a hierarchical list of files and directories to be used for the Composite design pattern example.
  • Contains the FileDirEntry trait that represents file and directory entries in a hierarchical list.
  • Contains the FileEntry struct that represents a file entry in a hierarchical list.

Constants

Functions

  • Example of using the “Composite” pattern.
  • Helper function to format the specified entry for display. Returns the fully-built string ready for output.
  • Helper function to display the contents of the hierarchical list of objects starting with the given object.