十五、freeRTOS_移植与内部实现

news2024/10/6 6:03:05

1.链表操作

1.1普通链表操作

#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct person {
	char *name;
	int age;
	struct person *couple;
};

struct person w;
struct person h;

int main(int argc, char **arg)
{
    
    HAL_Init();
    
    MX_USART1_UART_Init();
	
	w.name = "w";
	w.age  = 30;
	w.couple = &h;

	h.name = "h";
	h.age  = 30;
	h.couple = &w;
    
	printf("w's couple is %s\r\n", w.couple->name);
	
    
    while(1)
    {
    }
}

/*
w's couple is h
*/
#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct person {
	char *name;
	int age;
	struct person *next;
};

struct list {
	char *name; /* A班 */
	struct person *next;
};

int main(int argc, char **arg)
{
	struct list a_list;

	struct person p1;	
	
	a_list.name = "A";
	a_list.next = NULL;  /* 空链表 */
	
	p1.name = "a1";
	p1.next = NULL;
	
	a_list.next = &p1;	    
	
	printf("a list: %s\r\n", a_list.next->name);
    
    while(1)
    {
    }
}

/*
a list: a1
*/

1.2普通链表的创建和添加操作

1.3普通链表的删除操作

1.4普通链表的排序

#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct person {
	char *name;
	int age;
	struct person *next;
};

struct list {
	char *name; /* A班 */
	struct person *next;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->next = NULL;
}

void AddItemToList(struct list *pList, struct person *new_person)
{
	struct person *last;
	
	/* 如果是空链表 */
	if (pList->next == NULL)
	{
		pList->next = new_person;
		new_person->next =NULL;
		return;
	}
	
	last = pList->next;
	while (last->next)
	{
		last = last->next;
	}
	
	/* last->next == NULL */
	last->next = new_person;
	new_person->next =NULL;
}

void DelItemFromList(struct list *pList, struct person *person)
{
	struct person *p = pList->next;
	struct person *pre = NULL;
	
	/* 找到person */
	while (p != NULL && p != person)
	{
		/* 后面还有人, 移动到下一个 */
		pre = p;
		p = p->next;
	}
	
	/* 退出的条件: p==NULL, p == person */
	if (p == NULL)
	{
		printf("can not find the person to del\r\n");
		return;
	}
	
	if (pre == NULL) /* 前面无人, 表示要删除的是第1项 */
	{
		pList->next = p->next;
	}
	else
	{
		pre->next = p->next;
	}	
}

void SortList(struct list *pList)
{
	struct person *pre;
	struct person *next;
	
	char *tmp_name;
	int tmp_age;
	
	pre = pList->next;
	if (pre == NULL)
		return;
	
	while (pre)
	{
		next = pre->next;
		while (next)
		{
			if (pre->age > next->age)
			{
				/* 交换值 */
				tmp_name = pre->name;
				pre->name = next->name;
				next->name = tmp_name;

				tmp_age = pre->age;
				pre->age = next->age;
				next->age = tmp_age;
			}
			
			next = next->next;
		}
		
		pre = pre->next;
	}
	
}

void PrintList(struct list *pList)
{
	int i = 0;
	
	struct person *p = pList->next;
	
	while (p != NULL)
	{
		printf("person %d: %s is %d\r\n", i++, p->name, p->age);
		
		/* 后面还有人, 移动到下一个 */
		p = p->next;
	}
}

int main(int argc, char **arg)
{
	struct list a_list;
	int i;

	struct person p[] = {
		{"p1", 10, NULL},
		{"p2", 20, NULL},
		{"p3", 13, NULL},
		{"p4", 41, NULL},
		{"p5", 56, NULL},
		{"p6", 12, NULL},
		{"p7", 9, NULL},
		{"p8", 21, NULL},
		{NULL, 0, NULL},
	};
	
	
    HAL_Init();
    
    MX_USART1_UART_Init();

	InitList(&a_list, "A_class");

	i = 0;
	while (p[i].name != NULL)
	{
		AddItemToList(&a_list, &p[i]);
		i++;
	}

	printf("add all person:\r\n");
	PrintList(&a_list);
	
	DelItemFromList(&a_list, &p[3]);

	printf("del person %s:\r\n", p[3].name);
	PrintList(&a_list);

	DelItemFromList(&a_list, &p[0]);
	
	printf("del person %s:\r\n", p[0].name);
	PrintList(&a_list);
	
	SortList(&a_list);
	printf("sort list, all person:\r\n");
	PrintList(&a_list);
    
    while(1)
    {
    }
}

void Error_Handler(void)
{
    printf("Error\r\n");
    while(1)
    {
    }
}


/*
add all person:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p4 is 41
person 4: p5 is 56
person 5: p6 is 12
person 6: p7 is 9
person 7: p8 is 21
del person p4:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p5 is 56
person 4: p6 is 12
person 5: p7 is 9
person 6: p8 is 21
del person p1:
person 0: p2 is 20
person 1: p3 is 13
person 2: p5 is 56
person 3: p6 is 12
person 4: p7 is 9
person 5: p8 is 21
sort list, all person:
person 0: p7 is 9
person 1: p6 is 12
person 2: p3 is 13
person 3: p2 is 20
person 4: p8 is 21
person 5: p5 is 56
*/

1.5普通链表的改进

#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct person {
	char *name;
	int age;
	struct person *next;
};

struct list {
	char *name; /* A班 */
	struct person head;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->head.next = NULL;
}

void AddItemToList(struct list *pList, struct person *new_person)
{
	struct person *last = &pList->head;
	
	while (last->next)
	{
		last = last->next;
	}
	
	/* last->next == NULL */
	last->next = new_person;
	new_person->next =NULL;
}

void AddItemAfter(struct person *pre, struct person *new_person)
{
	new_person->next = pre->next;
	pre->next = new_person;
}

void DelItemFromList(struct list *pList, struct person *person)
{
	struct person *pre = &pList->head;
	
	/* 找到person */
	while (pre != NULL && pre->next != person)
	{
		pre = pre->next;
	}
	
	/* 没找到 */
	if (pre == NULL)
		return;
	else
		pre->next = person->next;
}

void SortList(struct list *pList)
{
	struct person *pre1 = &pList->head;
	struct person *pre2;
	struct person *cur = pre1->next;
	struct person *next;
	struct person *tmp;
		
	while (cur)
	{
		pre2 = cur;
		next = cur->next;
		while (next)
		{
			if (cur->age > next->age)
			{
				/* 交换节点 */
				/* 1. del cur */
				DelItemFromList(pList, cur);
				
				/* 2. del next */
				DelItemFromList(pList, next);
				
				/* 3. 在pre1之后插入next */
				AddItemAfter(pre1, next);
				
				/* 4. 在pre2之后插入cur */
				if (pre2 == cur)
					AddItemAfter(next, cur);
				else
					AddItemAfter(pre2, cur);
				
				/* 5. cur/next指针互换 */
				tmp = cur;
				cur = next;
				next = tmp;				
			}
			
			pre2 = next;
			next = next->next;
		}
		
		pre1 = cur;
		cur = cur->next;
	}
	
}

void PrintList(struct list *pList)
{
	int i = 0;
	
	struct person *p = pList->head.next;
	
	while (p != NULL)
	{
		printf("person %d: %s is %d\r\n", i++, p->name, p->age);
		
		/* 后面还有人, 移动到下一个 */
		p = p->next;
	}
}

int main(int argc, char **arg)
{
	struct list a_list;
	int i;

	struct person p[] = {
		{"p1", 10, NULL},
		{"p2", 20, NULL},
		{"p3", 13, NULL},
		{"p4", 41, NULL},
		{"p5", 56, NULL},
		{"p6", 12, NULL},
		{"p7", 9, NULL},
		{"p8", 21, NULL},
		{NULL, 0, NULL},
	};
	
	
    HAL_Init();
    
    MX_USART1_UART_Init();

	InitList(&a_list, "A_class");

	i = 0;
	while (p[i].name != NULL)
	{
		AddItemToList(&a_list, &p[i]);
		i++;
	}

	printf("add all person:\r\n");
	PrintList(&a_list);
	
	DelItemFromList(&a_list, &p[3]);

	printf("del person %s:\r\n", p[3].name);
	PrintList(&a_list);

	DelItemFromList(&a_list, &p[0]);
	
	printf("del person %s:\r\n", p[0].name);
	PrintList(&a_list);
	
	SortList(&a_list);
	printf("sort list, all person:\r\n");
	PrintList(&a_list);
    
    while(1)
    {
    }
}

void Error_Handler(void)
{
    printf("Error\r\n");
    while(1)
    {
    }
}


/*
add all person:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p4 is 41
person 4: p5 is 56
person 5: p6 is 12
person 6: p7 is 9
person 7: p8 is 21
del person p4:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p5 is 56
person 4: p6 is 12
person 5: p7 is 9
person 6: p8 is 21
del person p1:
person 0: p2 is 20
person 1: p3 is 13
person 2: p5 is 56
person 3: p6 is 12
person 4: p7 is 9
person 5: p8 is 21
sort list, all person:
person 0: p7 is 9
person 1: p6 is 12
person 2: p3 is 13
person 3: p2 is 20
person 4: p8 is 21
person 5: p5 is 56
*/

1.5.1普通链表为什么要改进 ?

没改之前,pre的头是list,p1的头是person,两个头不一样。

改进之后, pre的头是person,p1的头也是person,两个头是一致的,方便后期统一操作。

看代码,找区别!

没改之前

/*没改之前,主要区别是struct list结构体中的*next指针*/
/*InitList函数,pList->head = NULL; pList的头是list结构体*/

struct person {
	char *name;
	int age;
	struct person *next;
};

struct list {
	char *name; /* A班 */
	struct person *next;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->next = NULL;
}

改进之后

/*改进之后,主要区别是struct list结构体中的next指针*/
/*InitList函数,pList->head.next = NULL; pList的头是person结构体*/

struct person {
	char *name;
	int age;
	struct person *next;
};

struct list {
	char *name; /* A班 */
	struct person head;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->head.next = NULL;
}

1.6通用链表

#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node_t {
	struct node_t *next;
};

struct person {
	char *name;
	int age;
	struct node_t node;
};

struct list {
	char *name; /* A班 */
	struct node_t head;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->head.next = NULL;
}

void AddItemToList(struct list *pList, struct node_t *new_node)
{
	struct node_t *last = &pList->head;
	
	while (last->next)
	{
		last = last->next;
	}
	
	/* last->next == NULL */
	last->next = new_node;
	new_node->next =NULL;
}

void AddItemAfter(struct node_t *pre, struct node_t *new_node)
{
	new_node->next = pre->next;
	pre->next = new_node;
}

void DelItemFromList(struct list *pList, struct node_t *node)
{
	struct node_t *pre = &pList->head;
	
	/* 找到node */
	while (pre != NULL && pre->next != node)
	{
		pre = pre->next;
	}
	
	/* 没找到 */
	if (pre == NULL)
		return;
	else
		pre->next = node->next;
}

int CmpPersonAge(struct node_t *pre, struct node_t *next)
{
	struct person *p;
	struct person *n;
	
	p = (struct person *)((char *)pre - (unsigned int)&((struct person *)0)->node);
	n = (struct person *)((char *)next - (unsigned int)&((struct person *)0)->node);
	
	if (p->age < n->age)
		return -1;
	else
		return 0;
}

void SortList(struct list *pList)
{
	struct node_t *pre1 = &pList->head;
	struct node_t *pre2;
	struct node_t *cur = pre1->next;
	struct node_t *next;
	struct node_t *tmp;
		
	while (cur)
	{
		pre2 = cur;
		next = cur->next;
		while (next)
		{
			if (CmpPersonAge(cur, next) == 0)
			{
				/* 交换节点 */
				/* 1. del cur */
				DelItemFromList(pList, cur);
				
				/* 2. del next */
				DelItemFromList(pList, next);
				
				/* 3. 在pre1之后插入next */
				AddItemAfter(pre1, next);
				
				/* 4. 在pre2之后插入cur */
				if (pre2 == cur)
					AddItemAfter(next, cur);
				else
					AddItemAfter(pre2, cur);
				
				/* 5. cur/next指针互换 */
				tmp = cur;
				cur = next;
				next = tmp;				
			}
			
			pre2 = next;
			next = next->next;
		}
		
		pre1 = cur;
		cur = cur->next;
	}
	
}

void PrintList(struct list *pList)
{
	int i = 0;
	
	struct node_t *node = pList->head.next;
	struct person *p;
	
	while (node != NULL)
	{
		p = (struct person *)((char *)node - (unsigned int)&((struct person *)0)->node);;
		printf("person %d: %s is %d\r\n", i++, p->name, p->age);
		
		/* 后面还有人, 移动到下一个 */
		node = node->next;
	}
}

int main(int argc, char **arg)
{
	struct list a_list;
	int i;

	struct person p[] = {
//		{"p1", 10, {NULL}},
//		{"p2", 20, {NULL}},
//		{"p3", 13, {NULL}},
//		{"p4", 41, {NULL}},
//		{"p5", 56, {NULL}},
//		{"p6", 12, {NULL}},
//		{"p7", 9, {NULL}},
//		{"p8", 21, {NULL}},
//		{"p9", 22, {NULL}},
//		{"p10", 21, {NULL}},
//		{"p11", 20, {NULL}},
//		{NULL, 0, {NULL}},
		
		{"p1", 10, NULL},
		{"p2", 20, NULL},
		{"p3", 13, NULL},
		{"p4", 41, NULL},
		{"p5", 56, NULL},
		{"p6", 12, NULL},
		{"p7", 9, NULL},
		{"p8", 21, NULL},
		{"p9", 22, NULL},
		{"p10", 21, NULL},
		{"p11", 20, NULL},
		{NULL, 0, NULL},
	};
	
	
    HAL_Init();
    
    MX_USART1_UART_Init();

	InitList(&a_list, "A_class");

	i = 0;
	while (p[i].name != NULL)
	{
		AddItemToList(&a_list, &p[i].node);
		i++;
	}

	printf("add all person:\r\n");
	PrintList(&a_list);
	
	DelItemFromList(&a_list, &p[3].node);

	printf("del person %s:\r\n", p[3].name);
	PrintList(&a_list);

	DelItemFromList(&a_list, &p[0].node);
	
	printf("del person %s:\r\n", p[0].name);
	PrintList(&a_list);
	
	SortList(&a_list);
	printf("sort list, all person:\r\n");
	PrintList(&a_list);
    
    while(1)
    {
    }
}

void Error_Handler(void)
{
    printf("Error\r\n");
    while(1)
    {
    }
}

/*
add all person:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p4 is 41
person 4: p5 is 56
person 5: p6 is 12
person 6: p7 is 9
person 7: p8 is 21
person 8: p9 is 22
person 9: p10 is 21
person 10: p11 is 20
del person p4:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p5 is 56
person 4: p6 is 12
person 5: p7 is 9
person 6: p8 is 21
person 7: p9 is 22
person 8: p10 is 21
person 9: p11 is 20
del person p1:
person 0: p2 is 20
person 1: p3 is 13
person 2: p5 is 56
person 3: p6 is 12
person 4: p7 is 9
person 5: p8 is 21
person 6: p9 is 22
person 7: p10 is 21
person 8: p11 is 20
sort list, all person:
person 0: p7 is 9
person 1: p6 is 12
person 2: p3 is 13
person 3: p11 is 20
person 4: p2 is 20
person 5: p10 is 21
person 6: p8 is 21
person 7: p9 is 22
person 8: p5 is 56
*/

 1.6.1普通链表与通用链表的比较

普通链表

普通链表的缺点

AddItemToList函数的第二个参数是person结构体,如果后面要加入Dog结构体,或者加入Bird结构体,AddItemToList函数就不够通用,此时需要对Dog,Bird重写加入链表的函数,所以需要修改AddItemToList函数,使其更加通用。

通用链表

此时在链表头里面加入struct node_t head;让head存放next指向p1的node,p1的node存放next指向p2......依次类推。

这样做的好处就是:后面有Dog、Bird结构体时,链表头不需要改动,链表添加函数也不需要改动,只需要定义出Dog结构体就可以了,后面的添加链表函数通用。

struct Dog {

        char *name;

        int age;

        struct node_t node;

}

使用结构体的0地址偏移,找到结构体的首地址。 

1.7通用链表的三种实现方式

1. 引入概念container

struct person {
    struct node_t node;
    char *name;
    int age;
};

struct dog {
    struct node_t node;
    char *name;
    int age;
    char *class;
};

person里含有node,person就是node的"容器"、"container"。

dog里含有node,dog就是node的"容器"、"container"。

核心在于:怎么根据node找到container。

方法1

结构体中,node一定放在container中最前面:

struct person {
    struct node_t node;
    char *name;
    int age;
};

struct dog {
    struct node_t node;
    char *name;
    int age;
    char *class;
};

方法2

结构体中,根据node反算出container位置:适用于Linux,RT-Threah

struct person {
    char *name;
    int age;
    struct node_t node;
    char *address;
};

struct dog {
    char *name;
    int age;
    char *class;
    struct node_t node;    
};

方法3

node中,保存container地址:适用于FreeRTOS

struct node_t {
    void *container;
	struct node_t *next;
};

1.8双向链表

1.结构图

 2.判断尾部

上如中,person3是链表中最后一个链表项,它的下一个person是head:

person3.node.next == &list.head

3. 怎么插入新项

new_node->pre   = left_node;
new_node->next  = right_node;
left_node->next = new_node;
right_node->pre = new_node;

4. 怎么删除项 

left_node  = del_node->pre;
right_node = del_node->next;
left_node->next = right_node;
right_node->pre = left_node;

5.  初始化

6.  添加person节点

7. 在链表后面添加节点

#include "usart.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define container_of(ptr, type, member) \
	(type *)((char *)ptr - (unsigned int)&((type *)0)->member)

struct node_t {
	struct node_t *pre;
	struct node_t *next;
};

struct person {
	char *name;
	int age;
	struct node_t node;
};

struct list {
	char *name; /* A班 */
	struct node_t head;
};

void InitList(struct list *pList, char *name)
{
	pList->name = name;
	pList->head.next = &pList->head;
	pList->head.pre  = &pList->head;
}

void AddItemToList(struct list *pList, struct node_t *new_node)
{
	struct node_t *last = pList->head.pre;
	
	new_node->next  = &pList->head;
	last->next      = new_node;
	new_node->pre   = last;
	pList->head.pre = new_node;
}

void AddItemAfter(struct node_t *pre, struct node_t *new_node)
{
	struct node_t *right = pre->next;
	
	pre->next = new_node;
	new_node->next = right;
	
	right->pre = new_node;
	new_node->pre = pre;
}

void DelItemFromList(struct list *pList, struct node_t *node)
{
	struct node_t *left  = node->pre;
	struct node_t *right = node->next;
	
	left->next = right;
	right->pre = left;
}

int CmpPersonAge(struct node_t *pre, struct node_t *next)
{
	struct person *p;
	struct person *n;
	
	p = container_of(pre, struct person, node);
	n = container_of(next, struct person, node);
	
	if (p->age < n->age)
		return -1;
	else
		return 0;
}

void SortList(struct list *pList)
{
	struct node_t *pre1 = &pList->head;
	struct node_t *pre2;
	struct node_t *cur = pre1->next;
	struct node_t *next;
	struct node_t *tmp;
		
	while (cur != &pList->head)
	{
		pre2 = cur;
		next = cur->next;
		while (next != &pList->head)
		{
			if (CmpPersonAge(cur, next) == 0)
			{
				/* 交换节点 */
				/* 1. del cur */
				DelItemFromList(pList, cur);
				
				/* 2. del next */
				DelItemFromList(pList, next);
				
				/* 3. 在pre1之后插入next */
				AddItemAfter(pre1, next);
				
				/* 4. 在pre2之后插入cur */
				if (pre2 == cur)
					AddItemAfter(next, cur);
				else
					AddItemAfter(pre2, cur);
				
				/* 5. cur/next指针互换 */
				tmp = cur;
				cur = next;
				next = tmp;				
			}
			
			pre2 = next;
			next = next->next;
		}
		
		pre1 = cur;
		cur = cur->next;
	}
	
}

void PrintList(struct list *pList)
{
	int i = 0;
	
	struct node_t *node = pList->head.next;
	struct person *p;
	
	while (node != &pList->head)
	{
		p = container_of(node, struct person, node);
		printf("person %d: %s is %d\r\n", i++, p->name, p->age);
		
		/* 后面还有人, 移动到下一个 */
		node = node->next;
	}
}

int main(int argc, char **arg)
{
	struct list a_list;
	int i;

	struct person p[] = {
		{"p1", 10, {NULL}},
		{"p2", 20, {NULL}},
		{"p3", 13, {NULL}},
		{"p4", 41, {NULL}},
		{"p5", 56, {NULL}},
		{"p6", 12, {NULL}},
		{"p7", 9, {NULL}},
		{"p8", 21, {NULL}},
		{"p9", 22, {NULL}},
		{"p10", 21, {NULL}},
		{"p11", 20, {NULL}},
		{NULL, 0, {NULL}},
	};
	
	
    HAL_Init();
    
    MX_USART1_UART_Init();

	InitList(&a_list, "A_class");

	i = 0;
	while (p[i].name != NULL)
	{
		AddItemToList(&a_list, &p[i].node);
		i++;
	}

	printf("add all person:\r\n");
	PrintList(&a_list);
	
	DelItemFromList(&a_list, &p[3].node);

	printf("del person %s:\r\n", p[3].name);
	PrintList(&a_list);

	DelItemFromList(&a_list, &p[0].node);
	
	printf("del person %s:\r\n", p[0].name);
	PrintList(&a_list);
	
	SortList(&a_list);
	printf("sort list, all person:\r\n");
	PrintList(&a_list);
    
    while(1)
    {
    }
}

void Error_Handler(void)
{
    printf("Error\r\n");
    while(1)
    {
    }
}


/*
add all person:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p4 is 41
person 4: p5 is 56
person 5: p6 is 12
person 6: p7 is 9
person 7: p8 is 21
person 8: p9 is 22
person 9: p10 is 21
person 10: p11 is 20
del person p4:
person 0: p1 is 10
person 1: p2 is 20
person 2: p3 is 13
person 3: p5 is 56
person 4: p6 is 12
person 5: p7 is 9
person 6: p8 is 21
person 7: p9 is 22
person 8: p10 is 21
person 9: p11 is 20
del person p1:
person 0: p2 is 20
person 1: p3 is 13
person 2: p5 is 56
person 3: p6 is 12
person 4: p7 is 9
person 5: p8 is 21
person 6: p9 is 22
person 7: p10 is 21
person 8: p11 is 20
sort list, all person:
person 0: p7 is 9
person 1: p6 is 12
person 2: p3 is 13
person 3: p11 is 20
person 4: p2 is 20
person 5: p10 is 21
person 6: p8 is 21
person 7: p9 is 22
person 8: p5 is 56
*/

2.heap源码分析

3.任务源码分析

4.临界区进出

5.队列

6.信号量

7.事件组

8.任务通知

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1632763.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【免费Java系列】给大家出一些JavaSE基础第八天的内容案例 , 让大家更好的理解与掌握

String字符串 案例一 求取字符串的长度 public class Main {public static void main(String[] args) {String str "Hello World";String substring str.substring(6);System.out.println("截取后的字符串为&#xff1a;" substring);} }输出结果&…

使用新版ESLint,搭配Prettier使用的配置方式

概述 ESLint重大更新(9.0.0版本)后,将不再支持非扁平化配置文件,并且移除了与Prettier冲突的规则,也就是说与Prettier搭配使用,不再需要使用插件“eslint-config-prettier”来处理冲突问题。 注:使用新版的前提条件是Node.js版本必须是18.18.0、20.9.0,或者是>=21.1…

DiffSeg——基于Stable Diffusion的无监督零样本图像分割

概述 基于计算机视觉的模型的核心挑战之一是生成高质量的分割掩模。大规模监督训练的最新进展已经实现了跨各种图像风格的零样本分割。此外&#xff0c;无监督训练简化了分割&#xff0c;无需大量注释。尽管取得了这些进展&#xff0c;构建一个能够在没有注释的零样本设置中分…

解码Android应用:探索apk.sh的简化反向工程之道

解码Android应用&#xff1a;探索apk.sh的简化反向工程之道 引言 在当今数字化时代&#xff0c;Android应用的反向工程变得越来越重要。无论是应用开发者还是安全研究人员&#xff0c;都需要深入了解应用的内部结构和行为。然而&#xff0c;传统的反向工程过程常常繁琐复杂&a…

WiTUnet:一种集成CNN和Transformer的u型架构,用于改进特征对齐和局部信息融合

WiTUnet:一种集成CNN和Transformer的u型架构&#xff0c;用于改进特征对齐和局部信息融合 摘要IntroductionRelated workMethod WiTUnet: A U-Shaped Architecture Integrating CNN and Transformer for Improved Feature Alignment and Local Information Fusion. 摘要 低剂量…

LT6911UXB HDMI2.0 至四端口 MIPI DSI/CSI,带音频 龙迅方案

1. 描述LT6911UXB 是一款高性能 HDMI2.0 至 MIPI DSI/CSI 转换器&#xff0c;适用于 VR、智能手机和显示应用。HDMI2.0 输入支持高达 6Gbps 的数据速率&#xff0c;可为4k60Hz视频提供足够的带宽。此外&#xff0c;数据解密还支持 HDCP2.2。对于 MIPI DSI / CSI 输出&#xff0…

谁获得了全国交通运输行业最高科技奖项???

近期&#xff0c;2023年度中国交通运输协会科学技术奖表彰大会暨中国交通运输新技术新成果推广大会在株洲举办。会上&#xff0c;由交通运输部管理干部学院牵头&#xff0c;上海梦创双杨数据科技有限公司、深圳开源互联网安全技术有限公司、中国民航管理干部学院、北京信德科技…

SpringCloud Alibaba Nacos简单应用(三)

文章目录 SpringCloud Alibaba Nacos创建Nacos 的服务消费者需求说明/图解创建member-service-nacos-consumer-80 并注册到NacosServer8848创建member-service-nacos-consumer-80修改pom.xml创建application.yml创建主启动类业务类测试 SpringCloud Alibaba Nacos 创建Nacos 的…

爱国者随身wifi VS格行随身wifi对比测评!随身wiif哪个品牌好用?排名第一名随身WiFi格行随身WiFi真的靠谱吗?随身WiFi热销榜第一名!

出门手机信号不好网络卡顿&#xff0c;手机流量不够用&#xff0c;相信这是很多朋友都会遇到的问题。为了解决这个问题更多的会选择随身wifi&#xff0c;但是市面上随身wifi品牌众多&#xff0c;有不知道该选择哪一款。今天就来看看爱国者随身wifi和格行随身wifi哪款更好用&…

给我推荐5个非常好用的AI绘图生成软件

绘画领域随着科技的进步也得以革新&#xff0c;其中AI绘画软件是最为显著的创新之一。本文为大家推荐了5个极具实用价值的AI绘图生成软件&#xff0c;一同来看看吧&#xff01; 爱制作AI 功能介绍&#xff1a; 这款软件可以根据用户提供的图片或描述生成艺术绘画作品。它使用…

Graph Neural Networks(GNN)学习笔记

本学习笔记的组织结构是&#xff0c;先跟李沐老师学一下&#xff0c;再去kaggle上寻摸一下有没有类似的练习&#xff0c;浅做一下&#xff0c;作为一个了解。 ———————————0428更新—————————————— 课程和博客看到后面准备主要看两个&#xff1a;GCN和…

24.4.28(板刷dp,拓扑判环,区间dp+容斥算回文串总数)

星期一&#xff1a; 昨晚cf又掉分&#xff0c;小掉不算掉 补ABC350 D atc传送门 思路&#xff1a;对每个连通块&#xff0c;使其成为一个完全图&#xff0c;完全图的边数为 n*(n-1)/2 , 答案加上每个连通块成为完全图后的…

uniapp-css:拼图(不规则图片拼插)、碎片

拼图案例样式 高斯模糊的地方可以对应的使用fliter属性和opacity来调节样式。 其余碎片和图片对应: 这段代码实现了一个拼图效果的Vue组件。以下是对代码的详细解析: 模板部分: 在模板中使用v-for指令遍历imgs数组中的每个图片对象,为每个图片创建一个元素。 使用:cla…

vue3左树的全选和反选

<el-input v-model"filterText" placeholder"" style"width: 48%"/><el-button type"primary" click"handleSearch" class"ml-2">查找</el-button><el-radio-group v-model"form.choic…

leetcode-合并二叉树-90

题目要求 思路 1.如果两个结点都存在&#xff0c;就把对应的val加起来创建一个新的结点 2.如果有一个结点不存在&#xff0c;就用村在的那个结点 3.最后返回创建的头结点 代码实现 /*** struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* Tre…

数据结构--删除单链表中的某一个节点(时间复杂度控制为O(1))

题目描述&#x1f357; 只给定单链表中某个结点p(并非最后一个结点&#xff0c;即p->next!NULL)指针&#xff0c;删除该结点 思路分析&#x1f357; 结点不重要&#xff0c;&#xff0c;重要的是数据 不删自己&#xff0c;删除后面的结点: 1.把后面结点数据复制到当前 2.…

【Word】写论文,参考文献涉及的上标、尾注、脚注 怎么用

一、功能位置 二、脚注和尾注区别 1.首先脚注是一个汉语词汇&#xff0c;论文脚注就是附在论文页面的最底端&#xff0c;对某些内容加以说明&#xff0c;印在书页下端的注文。脚注和尾注是对文本的补充说明。 2.其次脚注一般位于页面的底部&#xff0c;可以作为文档某处内容的…

苹果发布开源模型;盘古大模型5.0将亮相;英伟达将收购 Run:ai

苹果首次发布开源语言模型 近期&#xff0c;苹果在 Hugging Face 发布了 OpenELM 系列模型。OpenELM 的关键创新是逐层扩展策略&#xff0c;该策略可在 transformer 模型的每一层中有效地分配参数&#xff0c;从而提高准确性。 与具有统一参数分配的传统语言模型不同&#xff…

Java中一个汉字究竟占几个字节?

前言 在今天&#xff0c;“Java中一个汉字占几个字符”的问题&#xff0c;让我提起了兴趣 在我的记忆中&#xff0c;一个字符应该是占两个字符的。但看了他人的回答 发现自己对这方面了解非常片面&#xff0c;于是痛定思痛潜心学习&#xff0c;写下这篇博客 总结不足文章目录 …

架构师技能:技术深度硬实力透过问题看本质--深入分析nginx偶尔502错误根因

以架构师的能力标准去分析每个问题&#xff0c;过后由表及里分析问题的本质&#xff0c;复盘总结经验&#xff0c;并把总结内容记录下来。当你解决各种各样的问题&#xff0c;也就积累了丰富的解决问题的经验&#xff0c;解决问题的能力也将自然得到极大的提升。励志做架构师的…