当前位置:网站首页>C # implements the operations of sequence table definition, insertion, deletion and search
C # implements the operations of sequence table definition, insertion, deletion and search
2022-06-29 12:53:00 【Dusk and starry sky】
In this paper,
C# Realize the definition of data structure of sequence table
1 Data table definition
public const int MaxSize = 50;// Define maximum length of linear table
///
/// Sequence table definition
///
struct SqList
{
//C# The array in the struct must specify its size ,SizeConst Array size
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSize)]
public object[] data ;
public int length;
};
2、 Sequential table insertion
///
/// Sequential table insertion
///
///
bool ListInSert(ref SqList L,int i,object e)//ref The function of is this . It passes the variable itself, not a copy, to the method , So modify the value of the original variable for the parameter
{
// Put the element e Insert sequence table L pass the civil examinations i A place
if (i < 1 || i > L.length + 1)
return false;
for (int j = L.length; j > i; j–)
L.data[j] = L.data[j - 1];
L.data[i - 1] = e;
L.length++;
return true;
}
3、 Sequential table deletion
///
/// Sequential table deletion
///
///
bool ListDelete(ref SqList L, int i, ref object e) {
if (i < 1 || i > L.length)
return false;
e = L.data[i - 1];// The deleted element is assigned to e
for (int j = i; j < L.length; j++)
L.data[j - 1] = L.data[j];
L.length–;
return true;
}
4、 Sequence table lookup
///
/// Sequence table lookup
///
///
int LocateElem(SqList L, object e) {
int i;
for ( i = 0; i < L.length - 1; i++)
if( L.data[i] == e)
return i+1;
return 0;
}
边栏推荐
- Matlab简单入门
- After class assignment of module 5 of the construction practice camp
- oracle 19c : change the user sys/system username pasword under Linux
- C # output the middle order traversal through the clue binary tree
- 解决问题:ModuleNotFoundError: No module named ‘pip‘
- Paper reproduction - ac-fpn:attention-guided context feature pyramid network for object detection
- 云龙开炮版飞机大战(完整版)
- Huffman coding
- Recommended model recurrence (I): familiar with torch rechub framework and use
- qt json
猜你喜欢

墨菲安全入选中关村科学城24个重点项目签约

倍福TwinCAT配置、调试第三方伺服详细讲解--以汇川IS620N为例子

AGCO AI frontier promotion (6.29)

Understanding of P value

MySQL 主从复制原理以及流程

Baidu cloud disk downloads large files without speed limit (valid for 2021-11 personal test)

C # indexe l'arbre binaire en traversant l'ordre moyen

MATLAB求极限

倍福PLC通过CANOpen通信控制伺服

How to create new user for ORACLE 19c (CDB & PDB)
随机推荐
ERP preparation of bill of materials Huaxia
倍福控制第三方伺服走CSV模式--以汇川伺服为例
Uncover the practice of Baidu intelligent test in the field of automatic test execution
求大数的阶乘 ← C语言
Gbase 8s extended external connection 1
Newton inequality
超 Nice 的表格响应式布局小技巧
[environment configuration]pwc-net
asp.net 项目使用aspnet_compiler.exe发布
Gbase8s database select has order by Clause 4
Gbase8s database select has order by Clause 5
Pygame 对图像进行翻转
nacos启动报错
C#实现二叉树的层次遍历
【LeetCode】14、最长公共前缀
How can colleges and universities build future oriented smart campus based on cloud native? Full stack cloud native architecture vs traditional IT architecture
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial
File contained log poisoning (user agent)
LeetCode_双指针_中等_328.奇偶链表
Viewing splitchunks code segmentation from MPX resource construction optimization