二叉节点
set 数据结构
<body>
<script src="./vue.js"></script>
<script>
//自身数据data,左节点left,右节点right
function Node(data,left,right){
this.data = data;
this.left = left;
this.right = right;
this.show = show;
}
function BST() {
this.root = null;//默认根节点为null
this.insert = insert;//插入操作
this.inOrder = inOrder;//中序遍历
this.getMin = getMin;//找出最小
this.getMax = getMax;//找出最大
this.find = find;//找出指定数据
}
//接收一个数组作为初始化
const s = new Set([1,2,3,33,4,3,4,5,3])
console.log(s);
console.log(s.size);
//利用set去重
let arr = [1,2,3,33,4,3,4,5,3]
let set = new Set(arr)
console.log(set);
console.log([...set]);
</script>
</body>
<body>
<script>
const s = new Set();
//add:添加
s.add('1').add('2')
console.log(s.size);//2
console.log(s);//Set(2) {'1', '2'}
//delete:删除
const result = s.delete('2')
console.log(result);//true
console.log(s.size);//1
console.log(s);//Set(1){'1'}
//has:判断是否是其成员have-has
const resultone = s.has('3')
const resultTwo = s.has('1')
console.log(resultone);//false
console.log(resultTwo);//true
//clear:清空成员
s.clear()
console.log(s.size);//0
</script>
</body>