Programming Notes ✍️ – Telegram
Programming Notes ✍️
12 subscribers
65 photos
1 file
22 links
Download Telegram
Linear Data Structures:

Array: A collection of elements of the same type stored in contiguous memory locations.

Linked List: A collection of elements linked together by pointers, allowing for dynamic insertion and deletion.

Queue: A First-In-First-Out (FIFO) structure where elements are added at the end and removed from the beginning.

Stack: A Last-In-First-Out (LIFO) structure where elements are added and removed from the top.

Non-Linear Data Structures:

Tree: A hierarchical structure where each node can have multiple child nodes.

Graph: A collection of nodes connected by edges, representing relationships between data elements.

Hash Table: A data structure that uses a hash function to map keys to values, allowing for fast lookup and insertion.


Applications of Data Structures
Data structures are widely used in various applications, including:

Database Management Systems: To store and manage large amounts of structured data.
Operating Systems: To manage memory, processes, and files.
Compiler Design: To represent source code and intermediate code.
Artificial Intelligence: To represent knowledge and perform reasoning.
Graphics and Multimedia: To store and process images, videos, and audio data.
Observers and events do not do the same thing at all.

An observer watches for specific things that happen within eloquent such as saving, saved, deleting, deleted (there are more but you should get the point). Observers are specifically bound to a model.

Events:

Events are actions that are driven by whatever the programmer wants. If you want to fire an event when somebody loads a page, you can do that. Unlike observers events can also be queue, and ran via laravels cron heartbeat. Events are programmer defined effectively. They give you the ability to handle actions that you would not want a user to wait for (excxample being the purchase of a pod cast)
Manifestation.
Integration.
Single Point of Failure

Just Running the system.
np-manager
np-executer
Running One-Time Scripts: Use npx for executing packages that you don't want to install globally, like testing a new package or tool.

Quick Prototyping: Leverage npx to quickly test libraries and tools without cluttering your global installation with unused packages.
During the installation process, Yarn installs multiple packages at once as contrasted to npm that installs each one at a time. Reinstallation was also pretty fast when using Yarn. It's because of its offline mode feature that uses a caching mechanism to allow for fast download of previously downloaded packages.
struct pnpm

{
"name": "package-manager-playground",
"version": "1.0.0",
"packageManager": "pnpm@6.24.4",
"pnpm": {
"packageExtensions": {
"styled-components": {
"dependencies": {
"react-is": "*"
}
},
"autoprefixer": {
"dependencies": {
"postcss": "*"
}
}
}
},
// ...
}
To increase the capacity of a slice one must create a new, larger slice and copy the contents of the original slice into it. This technique is how dynamic array implementations from other languages work behind the scenes.
func copy(dst, src []T) int
The looping piece of this common operation is made easier by the built-in copy function. As the name suggests, copy copies data from a source slice to a destination slice. It returns the number of elements copied.
t := make([]byte, len(s), (cap(s)+1)*2)
copy(t, s)
s = t
A common operation is to append data to the end of a slice. This function appends byte elements to a slice of bytes, growing the slice if necessary, and returns the updated slice value:

func AppendByte(slice []byte, data ...byte) []byte {
m := len(slice)
n := m + len(data)
if n > cap(slice) { // if necessary, reallocate
// allocate double what's needed, for future growth.
newSlice := make([]byte, (n+1)*2)
copy(newSlice, slice)
slice = newSlice
}
slice = slice[0:n]
copy(slice[m:n], data)
return slice
}
Go provides C-style /* */ block comments and C++-style // line comments. Line comments are the norm; block comments appear mostly as package comments, but are useful within an expression or to disable large swaths of code.
Go sorts packages based on the import relationships they form. When you import a package, it loads that package and everything it depends on first. That includes both code and init() functions. By the time Go starts to run your main package, it has already worked through every import it needed to get there. That means packages that live deeper in the graph run their init() functions earlier.
Declaration = ConstDecl | TypeDecl | VarDecl .
TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
Go is lexically scoped using blocks:



The scope of a predeclared identifier is the universe block.
The scope of an identifier denoting a constant, type, variable, or function (but not method) declared at top level (outside any function) is the package block.
The scope of the package name of an imported package is the file block of the file containing the import declaration.
The scope of an identifier denoting a method receiver, function parameter, or result variable is the function body.
The scope of an identifier denoting a type parameter of a function or declared by a method receiver begins after the name of the function and ends at the end of the function body.
The scope of an identifier denoting a type parameter of a type begins after the name of the type and ends at the end of the TypeSpec.
The scope of a constant or variable identifier declared inside a function begins at the end of the ConstSpec or VarSpec (ShortVarDecl for short variable declarations) and ends at the end of the innermost containing block.
The scope of a type identifier declared inside a function begins at the identifier in the TypeSpec and ends at the end of the innermost containing block.