Smart ways to implement various data structures in C structures and data that should be used more often

What are some clever (not ordinary) ways to implement data structures in C, and what are some data structures that should be used more often?

For example, what is the most efficient way (generating minimal overhead) for implementing a directed and cyclic graph with weighted edges in C?
I know that we can store distances in an array, as is done here , but what are other ways to implement this type of graph?

+3
source share
1 answer

, (a.k.a Handles).

, ( MS):

typedef struct linked_list_t* HLINKEDLIST;

, _list_t ( void).

, "" , ( ):

HLINKEDLIST LinkedListCreate();
LinkedListAdd(LLELEMENT v);
LinkedListCopy(HLINKEDLIST dst, const HLINKEDLIST src);

, PHLINKEDLIST ( ).

( , C). :

typedef void* LLELEMENT;

C . : http://www.amazon.com/Interfaces-Implementations-Techniques-Creating-Reusable/dp/0201498413

, LLELEMENT void *, , def :

typedef void* SYSTEMDATA;

SYSTEMDATA LLELEMENT, :

int QuerySystemData(SYSTEMDATA* sd);

:

QuerySystemData(lle);

lle LLELEMENT.

structs. , STRICT windows.h ( ). , , :

typedef struct __HWND 
{ 
int __handle; 
} __HWND; 

typedef __HWND* HWND; 

:

typedef int HWND;
typedef int HBITMAP;

, , ( ).

+1

Source: https://habr.com/ru/post/1746657/


All Articles