GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - BaseMax/ArrayListC: This is a simple implementation of an ArrayList in C using a struct, a pointer to the struct and a pointer to the array. The array is static and the size of the array is defined when the ArrayList is created.

BranchesTags
Open more actions menu

Latest commit

 

History

15 Commits
15 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
ArrayList.c
ArrayList.c
 
 
ArrayList.h
ArrayList.h
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
example.c
example.c
 
 

Repository files navigation

ArrayList C

This is a simple implementation of an ArrayList in C using a struct, a pointer to the struct and a pointer to the array. The array is static and the size of the array is defined when the ArrayList is created.

Functions

  • ArrayList* ArrayCreate(int n): Creates an ArrayList with a size of n.

  • void ArrayAppendFirst(ArrayList* list, int value): Add an element to the beginning of the list.

  • void ArrayAppendLast(ArrayList* list, int value): Appends a value to the end of the array.

  • void ArrayAppend(ArrayList* list, int value, int index): Appends a value to the array at the specified index.

  • void ArrayDelete(ArrayList* list, int index): Deletes the element at the given index.

  • void ArrayDeleteFirst(ArrayList* list): Deletes the first element of the array.

  • void ArrayDeleteLast(ArrayList* list): Deletes the last element of the array.

  • void ArrayPrint(ArrayList* list): Prints the array

  • void ArrayFree(ArrayList* list): Frees the memory

  • char* ArrayToString(ArrayList* list): Returns a string representation of the array

Usage

// Create an array list with maximum 10 value capacity.
ArrayList* list = ArrayCreate(10);

// Append a value to the last of the array list.
ArrayAppendLast(list, 10);
ArrayAppendLast(list, 20);
ArrayAppendLast(list, 30);
ArrayAppendLast(list, 40);

// Append a value to the first of the array list.
ArrayAppendFirst(list, 5);

// Append a value to the array list at the specified index.
ArrayAppend(list, 25, 2);

// Print the array list.
ArrayPrint(list);

// Delete a value from the array list at the specified index.
ArrayDelete(list, 3);

// Delete a value from the first of the array list.
ArrayDeleteFirst(list);

// Delete a value from the last of the array list.
ArrayDeleteLast(list);

// Print the array list.
ArrayPrint(list);

And the output is:

5 10 25 20 30 40
10 25 30

© Copyright Max Base, 2022

About

This is a simple implementation of an ArrayList in C using a struct, a pointer to the struct and a pointer to the array. The array is static and the size of the array is defined when the ArrayList is created.

Topics

arrayarray-carraylistarraylist-ccc-array

Resources

Readme
GPL-3.0 license
Activity

Stars

2 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.