小编use*_*ser的帖子

C程序制作链表的第二个副本

我正在编写一个C代码,将链接列表的内容复制到另一个列表中.我想知道是否有更有效的方法来做到这一点.

哪个更好?

struct node *copy(struct node *start1)
{
struct node *start2=NULL,*previous=NULL;

while(start1!=NULL)
{
    struct node * temp = (struct node *) malloc (sizeof(struct node));
    temp->info=start1->info;
    temp->link=NULL;

    if(start2==NULL)
    {
        start2=temp;
        previous=temp;
    }
    else
    {
        previous->link=temp;
        previous=temp;          
    }
    start1=start1->link;
}
return start2;
}
Run Code Online (Sandbox Code Playgroud)

要么

struct node *copy(struct node *start1)
{
    if(start1==NULL) return;
    struct node *temp=(struct node *) malloc(sizeof(struct node));
    temp->info=start1->info;
    temp->link=copy(start1->link);
    return temp;
}
Run Code Online (Sandbox Code Playgroud)

c algorithm linked-list

5
推荐指数
1
解决办法
3万
查看次数

如何为Presto和InfluxDB创建自定义连接器

我正在尝试为Presto和InfluxDB创建一个自定义连接器,以便Presto可以在InfluxDB上运行SQL查询.有没有这种连接器可用的例子?

Connectors are the source of all data for queries in Presto. Even if your data source doesn’t have underlying tables backing it, as long as you adapt your data source to the API expected by Presto, you can write queries against this data.
Run Code Online (Sandbox Code Playgroud)

我找到的用于编写连接器的唯一文档是:https: //prestodb.io/docs/current/develop/example-http.html

如果有人有其他例子,请你分享一下吗?

presto influxdb

3
推荐指数
1
解决办法
715
查看次数

标签 统计

algorithm ×1

c ×1

influxdb ×1

linked-list ×1

presto ×1