STL中使用的设计模式(标准模板库) [英] design patterns used in STL(standard template library)

查看:106
本文介绍了STL中使用的设计模式(标准模板库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习STL和设计模式。
i想知道有没有任何文档或链接说明如何在STL中实现设计模式
i做了谷歌,但不能获得太多的数据。

解决方案

我希望你的意思是可以在STL中识别哪些设计模式。



STL堆栈是一个容器适配器。适配器是一种设计模式。迭代器也是一种设计模式。 STL函数对象与命令模式相关。



模式:


  1. 适配器(容器适配器)


    • 堆栈

    • 队列

    • 优先级队列


  2. 迭代器

  3. 命令+适配器(功能适配器)

  4. 迭代器+适配器(迭代器适配器)


    • 反向迭代器

    • 插入迭代器

    • 流迭代器


  5. 模板方法(使用用户指定函数的STL算法)

  6. 哪个创作模式? (分配器)

这些模式的实现方式与面向对象设计中实现的方式截然不同。 Josuttis写道:STL概念与面向对象编程的原始思想相矛盾。这是导致您的问题的混乱。


I am learning STL and design patterns . i wanted to know is there any document or link that explains how design patterns are implemented in STL i did the google but not able to get much data

解决方案

I hope you mean, "which design patterns can be identified in the STL".

The STL stack is a container adapter. An adapter is a design pattern. The iterator is also a design pattern. The STL function objects are related to the command pattern.

Patterns:

  1. Adapter (container adapters)
    • stack
    • queues
    • priority queues
  2. Iterator
  3. Command + Adapter (function adapters)
  4. Iterator + Adapter (iterator adapters)
    • reverse iterators
    • insert iterators
    • stream iterators
  5. Template Method (STL algorithms using user-specified functions)
  6. Which creational pattern? (Allocators)

The way these patterns are implemented is very different from the way they are implemented in an object oriented design. Josuttis wrote "the STL concept contradicts the original idea of object-oriented programming". This is what is causing the confusion around your question.

这篇关于STL中使用的设计模式(标准模板库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆