线性表
线性表是最基本、最简单、也是最常用的一种数据结构。一个线性表是n个具有相同特性的数据元素的有限序列
前驱元素:若A元素在B元素的前面,则称A为B的前驱元素
后继元素:若B元素在A元素的后面,则称B为A的后继元素
线性表的特征:数据元素之间具有一种"一对一"的逻辑关系
1.第一个数据元素没有前驱,这个数据元素被称为头结点
2.最后一个数据元素没有后续,这个数据元素被称为尾结点
3.除了第一个和最后一个数据元素外,其他数据元素有且仅有一个前驱和一个后继
如果把线性表用数学语言来定义,则可以表示为(a1,...ai-1,ai,ai+1,...an),ai-1领先于ai,ai领先于ai+1,
称ai-1是ai的前驱元素,ai+1是ai的后继元素
线性表的分类:
线性表中数据存储的方式可以是顺序存储,也可以是链式存储,按照数据的存储方式不同,可以把线性表分为顺序表和链表
顺序表
顺序表是在计算机内存中以数组的形式保存的线性表,线性表的顺序存储是指用一组地址连续的存储单元,依次
存储线性表中的各个元素,使得线性表中再逻辑结构上响铃的数据元素存储在相邻的物理存储单元中,即通过数据元素
物理存储的相邻关系来反映数据元素之间逻辑上的相邻关系
顺序表的实现
顺序表API设计:
类名:SequenceList
构造方法:SequenceList(int capacity):创建容量为capacity的SequenceList对象
成员方法:1.public void clear():空置线性表
2.public boolean isEmpty():判断线性表是否为空,是返回true,否返回false
3.public int length():获取线性表中元素的个数
4.public T get(int i):读取并返回线性表中的第i个元素的值
5.public void insert(int i,T t):在线性表的第i个元素之前插入一个值为t的数据元素
6.public void insert(T t):向线性表中添加一个元素t
7.public T remove(int i):删除并返回线性表中第i个数据元素
8.public int indexOf(T t):返回线性表中首次出现的指定的数据元素的位序号,若不存在,则返回-1
成员变量:1.private T[] eles:存储元素的数组
2.private int N:当前线性表的长度
顺序表的遍历
一般作为容器存储数据,都需要外部提供遍历的方式,因此我们需要给顺序表提供遍历
在java中,遍历集合的方式一般都是用的是foreach循环,如果想让我们的SequenceList也能支持foreach循环
则需要做如下操作:
1.让SequenceList实现Iterable接口,重写iterator方法
2.在Sequencelist内部提供一个内部类SIterator,实现Iterator接口,重写hasNext方法和next方法
public class SequenceList<T> implements Iterable{
private T[] eles;
private int N;
public SequenceList(int capacity){
this.eles = (T[])new Object[capacity];
this.N = 0;
}
public void clear(){
this.N = 0;
}
public boolean isEmpty(){
return N==0;
}
public int length(){
return N;
}
public T get(int i){
return eles[i];
}
public void insert(T t){
eles[N++] = t;
}
public void insert(int i,T t){
for (int index=N;index>i;index--){
eles[index] = eles[index-1];
}
eles[i] = t;
N++;
}
public T remove(int i){
T current = eles[i];
for (int index=i;index<N-1;index++){
eles[index] = eles[index+1];
}
N--;
return current;
}
public int indexOf(T t){
for (int i=0;i<N;i++){
if (eles[i].equals(t)){
return i;
}
}
return -1;
}
@Override
public Iterator iterator() {
return new SIterator();
}
private class SIterator implements Iterator{
private int cusor;
public SIterator(){
this.cusor = 0;
}
@Override
public boolean hasNext() {
return cusor<N;
}
@Override
public Object next() {
return eles[cusor++];
}
}
}
public class SequenceListTest {
public static void main(String[] args) {
SequenceList<String> sl = new SequenceList<>(10);
sl.insert("姚明");
sl.insert("科比");
sl.insert("麦迪");
sl.insert(1,"詹姆斯");
for (Object s : sl) {
System.out.println(s);
}
System.out.println("=============================");
String getResult = sl.get(1);
System.out.println("获取索引1处的结果为:"+getResult);
String removeResult = sl.remove(0);
System.out.println("删除的元素是:"+removeResult);
sl.clear();
System.out.println("清空后的线性表中的元素个数为:"+sl.length());
}
}
顺序表的容量可变
我们在设计顺序表时,应该考虑它的容量的伸缩性,其实就是改变存储数据元素的数组的大小
1.添加元素时:添加元素时,应该检查当前数组的大小是否能容纳新的元素,如果不能容纳,
则需要创建新的容量更大的数组,我们这里创建一个是原数组两倍容量的新数组存储元素
2.移除元素时:移除元素时,应该检查当前数组的大小是否太大,比如正在用100个容量的数组存储
10个元素,这样就会造成内存空间的浪费,应该创建一个容器更小的数组存储元素,如果我们发现数据元素
的数量不是数组容量的1/4,则创建一个时原数组容量的1/2的新数组存储数组
public class SequenceList<T> implements Iterable{
private T[] eles;
private int N;
public SequenceList(int capacity){
this.eles = (T[])new Object[capacity];
this.N = 0;
}
public void clear(){
this.N = 0;
}
public boolean isEmpty(){
return N==0;
}
public int length(){
return N;
}
public T get(int i){
return eles[i];
}
public void insert(T t){
if (N==eles.length){
resize(2*eles.length);
}
eles[N++] = t;
}
public void insert(int i,T t){
if (N==eles.length){
resize(2*eles.length);
}
for (int index=N;index>i;index--){
eles[index] = eles[index-1];
}
eles[i] = t;
N++;
}
public T remove(int i){
T current = eles[i];
for (int index=i;index<N-1;index++){
eles[index] = eles[index+1];
}
N--;
if (N<eles.length/4){
resize(eles.length/2);
}
return current;
}
public int indexOf(T t){
for (int i=0;i<N;i++){
if (eles[i].equals(t)){
return i;
}
}
return -1;
}
public void resize(int newSize){
T[] temp = eles;
eles = (T[])new Object[newSize];
for (int i = 0; i <N; i++) {
eles[i] = temp[i];
}
}
@Override
public Iterator iterator() {
return new SIterator();
}
private class SIterator implements Iterator{
private int cusor;
public SIterator(){
this.cusor = 0;
}
@Override
public boolean hasNext() {
return cusor<N;
}
@Override
public Object next() {
return eles[cusor++];
}
}
}
public class SequenceListTest2 {
public static void main(String[] args) {
SequenceList<String> sl = new SequenceList<>(3);
sl.insert("张三");
sl.insert("李四");
sl.insert("王五");
sl.insert("赵六");
}
}
顺序表的时间复杂度
get(i):不难看出,不论数据元素量N有多大,只需要一次eles[i]就可以获取到对应的元素,所以时间复杂度为O(1)
insert(int i,T t):每一次插入,都需要把i位置后面的元素移动一次,随着元素数量N的增大,移动的元素也越多,时间复杂度为O(n)
remove(int i):每一次删除,都需要把i位置后面的元素移动一次,随着数据量N的增大,移动的元素也越多,时间复杂度为O(n)
由于顺序表的底层由数组实现,数组的长度是固定的,所以在操作的过程中涉及到了容器扩容操作。这样会导致顺序表在使用过程中
的时间复杂度不是线性的,在某些需要扩容的结点处,耗时会突增,尤其是元素越多,这个问题越明显
java中ArrayList实现
java中ArrayList集合的底层也是一种顺序表,使用数组实现,同样提供了增删改查以及扩容等功能
1.是否用数组实现
2.有没有扩容操作
3.有没有提供遍历方式
链表
链表是一种物理存储单元上非连续、非顺序的存储结构,其物理结构不能只管的表示数据元素的逻辑顺序,数据元素的逻辑顺序是
通过链表中的指针链接次序实现的。链表由一系列的结点(链表中的每一个元素称为结点)组成,结点可以在运行时动态生成
结点API设计:
类名:Node
构造方法:Node(T t,Node next):创建Node对象
成员变量:T item:存储数据
Node next:指向下一个结点
单向链表
单向链表是链表的一种,它由多个结点组成,每个结点都由一个数据域和一个指针域组成,数据域用来存储数据,指针域用来指向
其后继结点。链表的头结点的数据域不存储数据,指针域指向第一个真正存储数据的结点
单向链表API设计:
类名:LinkList
构造方法:LinkList():创建LinkList对象
成员方法:1.public void clear():空置线性表
2.public boolean isEmpty():判断线性表是否为空,是返回true,否返回false
3.public int length():获取线性表中元素的个数
4.public T get(int i):读取并返回线性表中的第i个元素的值
5.public void insert(int i,T t):在线性表的第i个元素之前插入一个值为t的数据元素
6.public void insert(T t):向线性表中添加一个元素t
7.public T remove(int i):删除并返回线性表中第i个数据元素
8.public int indexOf(T t):返回线性表中首次出现的指定的数据元素的位序号,若不存在,则返回-1
成员内部类:private class Node:结点类
成员变量:1.private Node head:记录首结点
2.private int N:记录链表的长度
public class LinkList<T> implements Iterable<T>{
private Node head;
private int N;
private class Node{
T item;
Node next;
public Node(T item,Node next){
this.item = item;
this.next = next;
}
}
public LinkList(){
this.head = new Node(null,null);
this.N = 0;
}
public void clear(){
head.next = null;
this.N = 0;
}
public boolean isEmpty(){
return N==0;
}
public int length(){
return N;
}
public T get(int i){
Node n = head.next;
for (int index=0;index<i;index++){
n=n.next;
}
return n.item;
}
public void insert(T t){
Node n = head;
while (n.next!=null){
n=n.next;
}
Node newNode = new Node(t,null);
n.next=newNode;
N++;
}
public void insert(int i,T t){
Node pre = head;
for (int index=0;index<=i-1;index++){
pre = pre.next;
}
Node curr = pre.next;
Node newNode = new Node(t, curr);
pre.next = newNode;
N++;
}
public T remove(int i){
Node pre = head;
for (int index=0;index<=i-1;index++){
pre = pre.next;
}
Node curr = pre.next;
Node nextNode = curr.next;
pre.next = nextNode;
N--;
return curr.item;
}
public int indexOf(T t){
Node n = head;
for (int i=0;n.next!=null;i++){
n=n.next;
if (n.item.equals(t)){
return i;
}
}
return -1;
}
@Override
public Iterator<T> iterator() {
return new LIterator();
}
private class LIterator implements Iterator{
private Node n;
public LIterator(){
this.n=head;
}
@Override
public boolean hasNext() {
return n.next!=null;
}
@Override
public Object next() {
n=n.next;
return n.item;
}
}
}
双向链表
双向链表也叫双向表,是链表的一种,它由多个结点组成,每个结点都由一个数据域和两个指针域组成,数据域用来存储数据,
其中一个指针域用来指向其后继结点,另一个指针域用来指向前驱结点。链表的头结点的数据域不存储数据,指向前驱结点的
指针域值为null,指向后继结点的指针域指向第一个真正存储数据的结点
结点API设计:
类名:Node
构造方法:Node(T t,Node pre,Node next):创建Node对象
成员变量:T item:存储数据
Node next:指向下一个结点
Node pre:指向上一个结点
双向链表API设计:
类名:TwoWayLinkList
构造方法:TwoWayLinkList():创建TwoWayLinkList对象
成员方法:1.public void clear():空置线性表
2.public boolean isEmpty():判断线性表是否为空,是返回true,否返回false
3.public int length():获取线性表中元素的个数
4.public T get(int i):读取并返回线性表中的第i个元素的值
5.public void insert(int i,T t):在线性表的第i个元素之前插入一个值为t的数据元素
6.public void insert(T t):向线性表中添加一个元素t
7.public T remove(int i):删除并返回线性表中第i个数据元素
8.public int indexOf(T t):返回线性表中首次出现的指定的数据元素的位序号,若不存在,则返回-1
9.public T getFirst():获取第一个元素
10.public T getLast():获取最后一个元素
成员内部类:private class Node:结点类
成员变量:1.private Node first:记录首结点
2.private Node last:记录尾结点
3.private int N:记录链表的长度
public class TwoWayLinkList<T> implements Iterable{
private Node head;
private Node last;
private int N;
private class Node {
public Node(T item, Node pre, Node next) {
this.item = item;
this.pre = pre;
this.next = next;
}
public T item;
public Node pre;
public Node next;
}
public TwoWayLinkList() {
this.head = new Node(null, null, null);
this.last = null;
this.N = 0;
}
public void clear() {
this.head.next = null;
this.last = null;
this.N = 0;
}
public boolean isEmpty() {
return N == 0;
}
public int length() {
return N;
}
public T getFirst() {
if (isEmpty()) {
return null;
}
return head.next.item;
}
public T getLast() {
if (isEmpty()) {
return null;
}
return last.item;
}
public void insert(T t) {
if (isEmpty()) {
Node newNode = new Node(t, head, null);
last = newNode;
head.next = last;
} else {
Node oldLast = last;
Node newNode = new Node(t, oldLast, null);
oldLast.next = newNode;
last = newNode;
}
N++;
}
public void insert(int i, T t) {
Node pre = head;
for (int index = 0; index < i; index++) {
pre = pre.next;
}
Node curr = pre.next;
Node newNode = new Node(t, pre, curr);
pre.next = newNode;
curr.pre = newNode;
N++;
}
public T get(int i){
Node n = head.next;
for (int index=0;index<i;index++){
n = n.next;
}
return n.item;
}
public T remove(int i) {
Node pre = head;
for (int index = 0; index < i; index++) {
pre = pre.next;
}
Node curr = pre.next;
Node nextNode = curr.next;
pre.next = nextNode;
nextNode.pre = pre;
N--;
return curr.item;
}
public int indexOf(T t) {
Node n = head;
for (int i=0;n.next!=null;i++){
n = n.next;
if (n.next.equals(t)){
return i;
}
}
return -1;
}
@Override
public Iterator iterator() {
return new TIterator();
}
private class TIterator implements Iterator{
private Node n;
public TIterator(){
this.n = head;
}
@Override
public boolean hasNext() {
return n.next!=null;
}
@Override
public Object next() {
n = n.next;
return n.item;
}
}
}
java中LinkedList实现
java中LinkedList集合也是使用双向链表实现,并提供了增删改查等相关方法
1.底层是否用双向链表实现
2.结点类是否有三个域
链表的复杂度分析
get(int i):每一次查询,都需要从链表的头部开始,依次向后查找,随着数据元素N的增多,比较的元素越多,时间复杂度为O(n)
insert(int i,T t):每一次插入,需要先找到i位置的前一个元素,然后完成插入操作,随着数据元素N的增多,查找元素越多,时间复杂度为O(n)
remove(int i):每一次移除,需要先找到i位置的前一个元素,然后完成插入操作,随着数据元素N的增多,查找的元素越多,时间复杂度为O(n)
相比较顺序表,链表插入和删除的时间复杂度虽然一样,但仍然有很大的优势,因为链表的物理地址是不连续的,它不需要预先
指定存储空间大小,或者在存储过程中涉及到扩容等操作,同时它并没有涉及元素的交换
相比较顺序表,链表的查询操作性能会比较低。因此,如果我们的程序中查询操作比较多,建议使用顺序表,增删操作比较多,建议使用链表
链表反转(面试高频)
反转API:
public void reverse():对整个链表反转
public Node reverse(Node curr):反转链表中的某个结点curr,并把反转后的curr结点返回
使用递归可以完成反转,递归反转其实就是从原链表的第一个存数据的结点开始,依次递归调用反转每一个结点,
直到把最后一个结点反转完毕,整个链表就反转完毕
public class LinkList<T> implements Iterable<T>{
private Node head;
private int N;
private class Node{
T item;
Node next;
public Node(T item,Node next){
this.item = item;
this.next = next;
}
}
public LinkList(){
this.head = new Node(null,null);
this.N = 0;
}
public void clear(){
head.next = null;
this.N = 0;
}
public boolean isEmpty(){
return N==0;
}
public int length(){
return N;
}
public T get(int i){
Node n = head.next;
for (int index=0;index<i;index++){
n=n.next;
}
return n.item;
}
public void insert(T t){
Node n = head;
while (n.next!=null){
n=n.next;
}
Node newNode = new Node(t,null);
n.next=newNode;
N++;
}
public void insert(int i,T t){
Node pre = head;
for (int index=0;index<=i-1;index++){
pre = pre.next;
}
Node curr = pre.next;
Node newNode = new Node(t, curr);
pre.next = newNode;
N++;
}
public T remove(int i){
Node pre = head;
for (int index=0;index<=i-1;index++){
pre = pre.next;
}
Node curr = pre.next;
Node nextNode = curr.next;
pre.next = nextNode;
N--;
return curr.item;
}
public int indexOf(T t){
Node n = head;
for (int i=0;n.next!=null;i++){
n=n.next;
if (n.item.equals(t)){
return i;
}
}
return -1;
}
@Override
public Iterator<T> iterator() {
return new LIterator();
}
private class LIterator implements Iterator{
private Node n;
public LIterator(){
this.n=head;
}
@Override
public boolean hasNext() {
return n.next!=null;
}
@Override
public Object next() {
n=n.next;
return n.item;
}
}
public void reverse(){
if (isEmpty()){
return;
}
reverse(head.next);
}
public Node reverse(Node curr){
if (curr.next==null){
head.next = curr;
return curr;
}
Node pre = reverse(curr.next);
pre.next = curr;
curr.next = null;
return curr;
}
}
public class LinkListTest2 {
public static void main(String[] args) {
LinkList<String> sl = new LinkList<>();
sl.insert("姚明");
sl.insert("科比");
sl.insert("麦迪");
sl.insert(1,"詹姆斯");
for (Object s : sl) {
System.out.println(s);
}
System.out.println("==============================");
sl.reverse();
for (Object s : sl) {
System.out.println(s);
}
}
}
快慢指针
快慢指针指的是定义两个指针,这两个指针的移动速度一快一慢,以此来制造出自己想要的差值,这个差值可以让我们找到链表上
相应的结点。一般情况下,快指针的移动步长为慢指针的两倍
中间值问题
public class FastSlowTest {
public static void main(String[] args) throws Exception{
Node<String> first = new Node<String>("aa",null);
Node<String> second = new Node<String>("bb",null);
Node<String> third = new Node<String>("cc",null);
Node<String> forth = new Node<String>("dd",null);
Node<String> fifth = new Node<String>("ee",null);
Node<String> sixth = new Node<String>("ff",null);
Node<String> seventh = new Node<String>("gg",null);
first.next = second;
second.next = third;
third.next = forth;
forth.next = fifth;
fifth.next = sixth;
sixth.next = seventh;
String mid = getMid(first);
System.out.println("中间值为:"+ mid);
}
public static String getMid(Node<String> first){
Node<String> fast = first;
Node<String> slow = first;
while (fast!=null&&fast.next!=null){
fast = fast.next.next;
slow = slow.next;
}
return slow.item;
}
private static class Node<T>{
T item;
Node next;
public Node(T item,Node next){
this.item = item;
this.next = next;
}
}
}
public class CircleListCheckTest {
public static void main(String[] args) throws Exception {
Node<String> first = new Node<String>("aa", null);
Node<String> second = new Node<String>("bb", null);
Node<String> third = new Node<String>("cc", null);
Node<String> forth = new Node<String>("dd", null);
Node<String> fifth = new Node<String>("ee", null);
Node<String> sixth = new Node<String>("ff", null);
Node<String> seventh = new Node<String>("gg", null);
first.next = second;
second.next = third;
third.next = forth;
forth.next = fifth;
fifth.next = sixth;
sixth.next = seventh;
seventh.next = third;
boolean circle = isCircle(first);
System.out.println("first链表中是否有环:"+ circle);
}
public static boolean isCircle(Node<String> first){
Node<String> fast = first;
Node<String> slow = first;
while (fast!=null&&fast.next!=null){
fast = fast.next.next;
slow = slow.next;
if (fast.equals(slow)){
return true;
}
}
return false;
}
private static class Node<T>{
T item;
Node next;
public Node(T item, Node next){
this.item = item;
this.next = next;
}
}
}
有环链表入口问题
当快慢指针相遇时, 我们可以判断到链表中有环,这时重新设定一个新指针指向链表的起点,且步长与慢指针一样为1,
则慢指针与"新"指针相遇的地方就是环的入口
public class CircleListInTest {
public static void main(String[] args) throws Exception {
Node<String> first = new Node<String>("aa", null);
Node<String> second = new Node<String>("bb", null);
Node<String> third = new Node<String>("cc", null);
Node<String> forth = new Node<String>("dd", null);
Node<String> fifth = new Node<String>("ee", null);
Node<String> sixth = new Node<String>("ff", null);
Node<String> seventh = new Node<String>("gg", null);
first.next = second;
second.next = third;
third.next = forth;
forth.next = fifth;
fifth.next = sixth;
sixth.next = seventh;
seventh.next = third;
Node<String> entrance = getEntrance(first);
System.out.println("first链表中环的入口结点元素为:"+ entrance.item);
}
public static Node getEntrance(Node<String> first){
Node<String> fast = first;
Node<String> slow = first;
Node<String> temp = null;
while (fast!=null&&fast.next!=null){
fast = fast.next.next;
slow = slow.next;
if (fast.equals(slow)){
temp = first;
continue;
}
if (temp!=null){
temp = temp.next;
if (temp.equals(slow)){
break;
}
}
}
return temp;
}
private static class Node<T>{
T item;
Node next;
public Node(T item, Node next){
this.item = item;
this.next = next;
}
}
}
循环链表
循环链表,顾名思义,链表整体要形成一个圆环状。在单向链表中,最后一个节点的指针为null,不指向任何结点,因为没有下一个元素了
要实现循环链表,我们只需要让单向链表的最后一个节点的指针指向头结点即可
public class Test {
public static void main(String[] args) throws Exception {
Node<Integer> first = new Node<Integer>("1", null);
Node<Integer> second = new Node<Integer>("2", null);
Node<Integer> third = new Node<Integer>("3", null);
Node<Integer> forth = new Node<Integer>("4", null);
Node<Integer> fifth = new Node<Integer>("5", null);
Node<Integer> sixth = new Node<Integer>("6", null);
Node<Integer> seventh = new Node<Integer>("7", null);
first.next = second;
second.next = third;
third.next = forth;
forth.next = fifth;
fifth.next = sixth;
sixth.next = seventh;
seventh.next = first;
}
}
约瑟夫问题
问题描述:
传说有这样一个故事,在罗马人占领乔塔帕特后,39个犹太人与约瑟夫及他的朋友躲到一个洞中,39个犹太人决定宁愿死也不要被
敌人抓到,于是决定了一个自杀方式,41个人排成一个圆圈,第一个人从1开始报数,依次往后,如果有人报数到3,那么这个人就
必须自杀,然后再由他的下一个人重新开始从1开始报数,直到所有人都自杀身亡为止。然而约瑟夫和他的朋友并不想遵从。于是,
约瑟夫要他的朋友先假装遵从,他将朋友与自己安排在第16个与第31个位置,从而逃过了这场死亡游戏
问题转换:41个人坐一圈,第一个人编号为1,第二个人编号为2,第n个人编号为n
1.编号为1的人开始报数,依次向后,报数为3的那个人退出圈
2.自退出那个人开始的下一个人再次从1开始报数,以此类推
3.求最后退出的那个人的编号
public class JosephTest {
public static void main(String[] args) {
Node<Integer> first = null;
Node<Integer> pre = null;
for (int i = 1; i <=41 ; i++) {
if (i==1){
first = new Node<>(1,null);
pre = first;
continue;
}
Node<Integer> newNode = new Node<>(i, null);
pre.next = newNode;
pre = newNode;
if (i==41){
pre.next = first;
}
}
int count = 0;
Node<Integer> n = first;
Node<Integer> before = null;
while (n!=n.next){
count++;
if (count==3){
before.next = n.next;
System.out.print(n.item+",");
count = 0;
n = n.next;
}else{
before = n;
n = n.next;
}
}
System.out.println(n.item);
}
private static class Node<T>{
T item;
Node next;
public Node(T item, Node next){
this.item = item;
this.next = next;
}
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧