Test blockchain Storage Structure

Source: Internet
Author: User
Code
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. collections;
Using system. Collections. Specialized;
Using system. Threading;

Using system. reflection;
Using system. Data;

Namespace testarray
{
Class Program
{
/// <Summary>
/// Test the chain Storage Class Structure
/// </Summary>
/// <Param name = "ARGs"> </param>
Static void Main (string [] args)
{
String s1 = "red ";
String s2 = "blue ";
String s3 = "yellow ";

Structure <string> l = new structure <string> ();
L. addData (new primary node <string> (s1 ));
L. addData (new worker node <string> (s2 ));
L. addData (new vertex node <string> (s3 ));
L. displayData ();

Console. ReadLine ();
}
}

// Data element storage Representation
Class worker node <T>
{
T data;
Random node <T> next; // links randomly stored elements by referencing them.

Public writable node (T val)
{
Data = val;
Next = NULL;
}

Public t data
{
Get {return data ;}
Set {DATA = value ;}
}

Public writable node <t> next
{
Get {return next ;}
Set {next = value ;}
}
}


// Storage representation and Algorithm Implementation of Data Element relationships
Class Structure <T>
{
Worker node <T> first;
Worker node <T> current;

Public topology structure ()
{
First = null;
}

Public void addData (writable node <T> var)
{
If (first = null)
{
First = var;
Current = var;
Return;
}
Else
{
Current. Next = var;
Current = var;
}
}

Public void displayData ()
{
Current = first;
While (current! = Null)
{
Console. Write (current. Data + "");
Current = current. Next;
}
}
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.