obj-m与obj-y的区别

obj-m与obj-y的区别

obj-y +=xxx.o该模块编译到zImage

obj-m +=xxx.o该模块不会编译到zImage

但会生成一个独立的xxx.ko 静态编译

帮我给以下代码写注释void swap(int* a, int* b) { int tmp = *a; *a = *b, *b = tmp; } struct DisjointSetUnion { int *f, *size; int n, setCount; }; void initDSU(struct DisjointSetUnion* obj, int n) { obj->f = malloc(sizeof(int) * n); obj->size = malloc(sizeof(int) * n); obj->n = n; obj->setCount = n; for (int i = 0; i < n; i++) { obj->f[i] = i; obj->size[i] = 1; } } int find(struct DisjointSetUnion* obj, int x) { return obj->f[x] == x ? x : (obj->f[x] = find(obj, obj->f[x])); } int unionSet(struct DisjointSetUnion* obj, int x, int y) { int fx = find(obj, x), fy = find(obj, y); if (fx == fy) { return false; } if (obj->size[fx] < obj->size[fy]) { swap(&fx, &fy); } obj->size[fx] += obj->size[fy]; obj->f[fy] = fx; obj->setCount--; return true; } int connected(struct DisjointSetUnion* obj, int x, int y) { return find(obj, x) == find(obj, y); } struct Tuple { int x, y, z }; int cmp(const struct Tuple* a, const struct Tuple* b) { return a->z - b->z; } int minimumEffortPath(int** heights, int heightsSize, int* heightsColSize) { int m = heightsSize; int n = heightsColSize[0]; struct Tuple edges[n * m * 2]; int edgesSize = 0; for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { int id = i * n + j; if (i > 0) { edges[edgesSize].x = id - n; edges[edgesSize].y = id; edges[edgesSize++].z = fabs(heights[i][j] - heights[i - 1][j]); } if (j > 0) { edges[edgesSize].x = id - 1; edges[edgesSize].y = id; edges[edgesSize++].z = fabs(heights[i][j] - heights[i][j - 1]); } } } qsort(edges, edgesSize, sizeof(struct Tuple), cmp); struct DisjointSetUnion* uf = malloc(sizeof(struct DisjointSetUnion)); initDSU(uf, m * n); int ans = 0; for (int i = 0; i < edgesSize; i++) { unionSet(uf, edges[i].x, edges[i].y); if (connected(uf, 0, m * n - 1)) { ans = edges[i].z; break; } } return ans; }
05-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值