●关联容器(也是ADT 抽象数据类型)
map,set,multiset,multimap
●有序容器
vector,list
1.std::map底层的数据结构为平衡二叉树(红黑树)进行实现。
2.二叉搜索树结构(代码)
class Node:
def __init__(self, data,color,parent):
self.left = None
self.right = None
self.data = data
self.parent = parent
self.color = color
class Tree:
def __init__(self,compare):
self.root = None
self.node_count = 0
self.key_compare = compare
●遍历抽象化
def visit(node, func):
if node:
printTree(node.left)
func(node.data)
printTree(node.right)