Skip to content

Commit

Permalink
Change the operations sequence of the likedlist's insert() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
krahets committed Feb 27, 2023
1 parent 18f2ec4 commit 9ea24e8
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion codes/c/chapter_array_and_linkedlist/linked_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/* 在链表的结点 n0 之后插入结点 P */
void insert(ListNode* n0, ListNode* P) {
ListNode *n1 = n0->next;
n0->next = P;
P->next = n1;
n0->next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/cpp/chapter_array_and_linkedlist/linked_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/* 在链表的结点 n0 之后插入结点 P */
void insert(ListNode* n0, ListNode* P) {
ListNode* n1 = n0->next;
n0->next = P;
P->next = n1;
n0->next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/csharp/chapter_array_and_linkedlist/linked_list.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class linked_list
public static void insert(ListNode n0, ListNode P)
{
ListNode? n1 = n0.next;
n0.next = P;
P.next = n1;
n0.next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/dart/chapter_array_and_linkedlist/linked_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class LinkedList {
/* 在链表的结点 n0 之后插入结点 P */
void insert(ListNode n0, ListNode P) {
ListNode? n1 = n0.next;
n0.next = P;
P.next = n1;
n0.next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/go/chapter_array_and_linkedlist/linked_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
/* 在链表的结点 n0 之后插入结点 P */
func insertNode(n0 *ListNode, P *ListNode) {
n1 := n0.Next
n0.Next = P
P.Next = n1
n0.Next = P
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/java/chapter_array_and_linkedlist/linked_list.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class linked_list {
/* 在链表的结点 n0 之后插入结点 P */
static void insert(ListNode n0, ListNode P) {
ListNode n1 = n0.next;
n0.next = P;
P.next = n1;
n0.next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const { ListNode } = require("../include/ListNode");
/* 在链表的结点 n0 之后插入结点 P */
function insert(n0, P) {
const n1 = n0.next;
n0.next = P;
P.next = n1;
n0.next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/python/chapter_array_and_linkedlist/linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
""" 在链表的结点 n0 之后插入结点 P """
def insert(n0, P):
n1 = n0.next
n0.next = P
P.next = n1
n0.next = P

""" 删除链表的结点 n0 之后的首个结点 """
def remove(n0):
Expand Down
2 changes: 1 addition & 1 deletion codes/swift/chapter_array_and_linkedlist/linked_list.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import utils
/* 在链表的结点 n0 之后插入结点 P */
func insert(n0: ListNode, P: ListNode) {
let n1 = n0.next
n0.next = P
P.next = n1
n0.next = P
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { printLinkedList } from '../module/PrintUtil';
/* 在链表的结点 n0 之后插入结点 P */
function insert(n0: ListNode, P: ListNode): void {
const n1 = n0.next;
n0.next = P;
P.next = n1;
n0.next = P;
}

/* 删除链表的结点 n0 之后的首个结点 */
Expand Down
2 changes: 1 addition & 1 deletion codes/zig/chapter_array_and_linkedlist/linked_list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const inc = @import("include");
// 在链表的结点 n0 之后插入结点 P
pub fn insert(n0: ?*inc.ListNode(i32), P: ?*inc.ListNode(i32)) void {
var n1 = n0.?.next;
n0.?.next = P;
P.?.next = n1;
n0.?.next = P;
}

// 删除链表的结点 n0 之后的首个结点
Expand Down

0 comments on commit 9ea24e8

Please sign in to comment.