P-p-H-d /
mlib
M*LIB is a library of generic and type safe containers / data structures in pure C language (C99 / C11) for a wide collection of container (comparable to the C++ STL).
Loading repository data…
srdja / repository
A library of generic data structures for the C language.
Collections-C is a library of generic data structures for the C language.
Structures that store data in the form of void*.
| Container | description |
|---|---|
CC_Array | A dynamic array that expands automatically as elements are added. |
CC_List | Doubly Linked list. |
CC_SList | Singly linked list. |
CC_Deque | A dynamic array that supports amortized constant time insertion and removal at both ends and constant time access. |
CC_HashTable | An unordered key-value map. Supports best case amortized constant time insertion, removal, and lookup of values. |
CC_TreeTable | An ordered key-value map. Supports logarithmic time insertion, removal and lookup of values. |
CC_HashSet | An unordered set. The lookup, deletion, and insertion are performed in amortized constant time and in the worst case in amortized linear time. |
CC_TreeSet | An ordered set. The lookup, deletion, and insertion are performed in logarithmic time. |
CC_Queue | A FIFO (first in first out) structure. Supports constant time insertion, removal and lookup. |
CC_Stack | A LIFO (last in first out) structure. Supports constant time insertion, removal and lookup. |
CC_PQueue | A priority queue. |
CC_RingBuffer | A ring buffer. |
CC_TSTTable | A ternary search tree table. Supports insertion, search, iteration, and deletion. |
int value = 20;
CC_Array *array;
if (cc_array_new(&array) != CC_OK) { /*Create a new array.*/
// handle error
}
if (cc_array_add(&array, (void*) &value) != CC_OK) { /* Add the pointer to the value to the array */
// handle error
}
Structures that store data of arbitrary length directly.
| Container | description |
|---|---|
CC_ArraySized | A dynamic array that expands automatically as elements are added. |
int value = 20;
CC_SizedArray *array;
if (cc_sized_array_new(sizeof(int), &array) != CC_OK) { /* Create a new array that stores values the size of an int*/
// handle error
}
if (cc_sized_array_add(&array, &value) != CC_OK) { /* Copy the value into the array */
// handle error
}
Memory pools are pre-allocated blocks of contiguous memory
| Container | description |
|---|---|
CC_DynamicPool | On the heap, potentially expandable memory pool |
CC_StaticPool | Fixed pool |
/* CC_StaticPool can enable the use of the structures on the stack */
#include "memory/cc_static_pool.h"
#include "cc_list.h"
CC_StaticPool *pool;
// Alloc wrappers
void *pool_malloc(size_t size) {cc_static_pool_malloc(size, pool);}
void *pool_calloc(size_t count, size_t size) {cc_static_pool_calloc(count, size, pool);}
void pool_free(void* ptr) {cc_static_pool_free(ptr, pool);}
int main(int argc, char **argv) {
uint8_t buffer[2000]; /* Large enough buffer. */
cc_static_pool_new(sizeof(buffer), 0, buffer, buffer, &pool); /* allocate the pool structure inside the buffer */
CC_ListConf conf; /* Create a new list config */
cc_list_conf_init(&conf);
conf.mem_alloc = pool_malloc; /* Set list memory allocators to pool allocators */
conf.mem_calloc = pool_calloc;
conf.mem_free = pool_free;
CC_List* list;
cc_list_new_conf(&conf, &list); /* The newly created list will be allocated inside the "buffer" array*/
// Use the list
return 0;
}
These packages can usually be installed through your distributions package manager.
To build the project, we first need to create a separate build directory (if it doesn't already exist):
mkdir build
From this directory we can run the cmake command and configure the build:
cmake .. or cmake -DSHARED=True to make Collections-C build as a shared librarycmake -DSHARED=False to build a static libraryOnce cmake is done generating makefiles, we can build the library by running make inside our build directory.
An example of cloning and building a static library:
git clone https://github.com/Collections-C.git
cd Collections-C
mkdir build
cd build
cmake -DSHARED=False
make
To run tests (from the build directory):
make test
To run individual tests, simply run the appropriate executable. For example:
build/test/array_test
To install the library run:
sudo make install
By default the libraries and headers will be installed in /usr/local/lib/ and /usr/local/include directories.
You have to make the system's runtime aware of the location of the new library to be able to run dynamically linked applications. This might be as simple as running the following command if your /etc/ld.so.conf contains the install directory.
Note: macOS doesn't support ldconfig.
sudo ldconfig
If we already built and installed the library, we can write a simple hello world program and save it to a file named hello.c:
#include <stdio.h>
#include <collectc/cc_array.h>
int main(int argc, char **argv) {
// Create a new array
CC_Array *ar;
cc_array_new(&ar);
// Add a string to the array
cc_array_add(ar, "Hello World!\n");
// Retreive the string and print it
char *str;
cc_array_get_at(ar, 0, (void*) &str);
printf("%s", str);
return 0;
}
Now we need to compile and link our program. Since make builds both the static and the dynamic library we can choose which one we wish to link into our program.
If we wish to statically link the library to our program we can pass the -static flag to the compiler
Note: On macOS, the -static flag is not very friendly (it requires that all the libraries are statically linked). So we can replace -static -lcollectc with the full path to the static library. Which is /usr/local/lib/libcollectc.a by default.
gcc hello.c -static -lcollectc -o hello
or similarly when compiling with clang:
clang hello.c -static -lcollectc -o hello
This will link the library by copying it into the executable. We can use this option if we don't wish to have Collections-C as a runtime dependency, however this comes at the expense of generating a larger executable.
We can also choose to link with the library dynamically at runtime. This is the default behaviour if omit the -static compiler flag:
gcc hello.c -lcollectc -o hello
or with clang:
clang hello.c -lcollectc -o hello
Linking dynamically produces a smaller executable, but requires libcollectc.so to be present on every system on which the program is going to be executed.
Sometimes the compiler may have trouble finding the library or the headers. This is usually because it's looking for them in the wrong directory, which may happen if the library or the headers or both are installed in a non-standard directory or not installed at all.
If this is the case, we can explicitly tell the compiler where to look for them by passing the -I[path to headers] and -L[path to libraries] options:
gcc hello.c `pkg-config --cflags --libs collectionc` -o hello
If everything went well with the compilation we can run the executable:
./hello
and it should print Hello, World! to the console.
Contributions are welcome.
If you have a feature request, or have found a bug, feel free to open a new issue. If you wish to contribute code, see CONTRIBUTING.md for more details.
Selected from shared topics, language and repository description—not editorial ratings.
P-p-H-d /
M*LIB is a library of generic and type safe containers / data structures in pure C language (C99 / C11) for a wide collection of container (comparable to the C++ STL).
adaptive-machine-learning /
Enhanced machine learning library tailored for data streams, featuring a Python API integrated with MOA backend support. This unique combination empowers users to leverage a wide array of existing algorithms efficiently while fostering the development of new methodologies in both Python and Java.
mxschmitt /
Golang library which provide an algorithm to generate all combinations out of a given string array.
rick2785 /
I specifically cover the following topics: Java primitive data types, declaration statements, expression statements, importing class libraries, excepting user input, checking for valid input, catching errors in input, math functions, if statement, relational operators, logical operators, ternary operator, switch statement, and looping. How class variables differ from local variables, Java Exception handling, the difference between run time and checked exceptions, Arrays, and UML Diagrams. Monsters gameboard, Java collection classes, Java ArrayLists, Linked Lists, manipulating Strings and StringBuilders, Polymorphism, Inheritance, Protected, Final, Instanceof, interfaces, abstract classes, abstract methods. You need interfaces and abstract classes because Java doesn't allow you to inherit from more than one other class. Java threads, Regular Expressions, Graphical User Interfaces (GUI) using Java Swing and its components, GUI Event Handling, ChangeListener, JOptionPane, combo boxes, list boxes, JLists, DefaultListModel, using JScrollpane with JList, JSpinner, JTree, Flow, Border, and Box Layout Managers. Created a calculator layout with Java Swing's GridLayout, GridBagLayout, GridBagConstraints, Font, and Insets. JLabel, JTextField, JComboBox, JSpinner, JSlider, JRadioButton, ButtonGroup, JCheckBox, JTextArea, JScrollPane, ChangeListener, pack, create and delete files and directories. How to pull lists of files from directories and manipulate them, write to and read character streams from files. PrintWriter, BufferedWriter, FileWriter, BufferedReader, FileReader, common file exceptions Binary Streams - DataOutputStream, FileOutputStream, BufferedOutputStream, all of the reading and writing primitive type methods, setup Java JDBC in Eclipse, connect to a MySQL database, query it and get the results of a query. JTables, JEditorPane Swing component. HyperlinkEvent and HyperlinkListener. Java JApplet, Java Servlets with Tomcat, GET and POST methods, Java Server Pages, parsing XML with Java, Java XPath, JDOM2 library, and 2D graphics. *Created a Java Paint Application using swing, events, mouse events, Graphics2D, ArrayList *Designed a Java Video Game like Asteroids with collision detection and shooting torpedos which also played sound in a JFrame, and removed items from the screen when they were destroyed. Rotating polygons, and Making Java Executable. Model View Controller (MVC) The Model is the class that contains the data and the methods needed to use the data. The View is the interface. The Controller coordinates interactions between the Model and View. DESIGN PATTERNS: Strategy design patternis used if you need to dynamically change an algorithm used by an object at run time. The pattern also allows you to eliminate code duplication. It separates behavior from super and subclasses. The Observer pattern is a software design pattern in which an object, called the subject (Publisher), maintains a list of its dependents, called observers (Subscribers), and notifies them automatically of any state changes, usually by calling one of their methods. The Factory design pattern is used when you want to define the class of an object at runtime. It also allows you to encapsulate object creation so that you can keep all object creation code in one place The Abstract Factory Design Pattern is like a factory, but everything is encapsulated. The Singleton pattern is used when you want to eliminate the option of instantiating more than one object. (Scrabble letters app) The Builder Design Pattern is used when you want to have many classes help in the creation of an object. By having different classes build the object you can then easily create many different types of objects without being forced to rewrite code. The Builder pattern provides a different way to make complex objects like you'd make using the Abstract Factory design pattern. The Prototype design pattern is used for creating new objects (instances) by cloning (copying) other objects. It allows for the adding of any subclass instance of a known super class at run time. It is used when there are numerous potential classes that you want to only use if needed at runtime. The major benefit of using the Prototype pattern is that it reduces the need for creating potentially unneeded subclasses. Java Reflection is an API and it's used to manipulate classes and everything in a class including fields, methods, constructors, private data, etc. (TestingReflection.java) The Decorator allows you to modify an object dynamically. You would use it when you want the capabilities of inheritance with subclasses, but you need to add functionality at run time. It is more flexible than inheritance. The Decorator Design Pattern simplifies code because you add functionality using many simple classes. Also, rather than rewrite old code you can extend it with new code and that is always good. (Pizza app) The Command design pattern allows you to store a list of commands for later use. With it you can store multiple commands in a class to use over and over. (ElectronicDevice app) The Adapter pattern is used when you want to translate one interface of a class into another interface. Allows 2 incompatible interfaces to work together. It allows the use of the available interface and the target interface. Any class can work together as long as the Adapter solves the issue that all classes must implement every method defined by the shared interface. (EnemyAttacker app) The Facade pattern basically says that you should simplify your methods so that much of what is done is in the background. In technical terms you should decouple the client from the sub components needed to perform an operation. (Bank app) The Bridge Pattern is used to decouple an abstraction from its implementation so that the two can vary independently. Progressively adding functionality while separating out major differences using abstract classes. (EntertainmentDevice app) In a Template Method pattern, you define a method (algorithm) in an abstract class. It contains both abstract methods and non-abstract methods. The subclasses that extend this abstract class then override those methods that don't make sense for them to use in the default way. (Sandwich app) The Iterator pattern provides you with a uniform way to access different collections of Objects. You can also write polymorphic code because you can refer to each collection of objects because they'll implement the same interface. (SongIterator app) The Composite design pattern is used to structure data into its individual parts as well as represent the inner workings of every part of a larger object. The composite pattern also allows you to treat both groups of parts in the same way as you treat the parts polymorphically. You can structure data, or represent the inner working of every part of a whole object individually. (SongComponent app) The flyweight design pattern is used to dramatically increase the speed of your code when you are using many similar objects. To reduce memory usage the flyweight design pattern shares Objects that are the same rather than creating new ones. (FlyWeightTest app) State Pattern allows an object to alter its behavior when its internal state changes. The object will appear to change its class. (ATMState) The Proxy design pattern limits access to just the methods you want made accessible in another class. It can be used for security reasons, because an Object is intensive to create, or is accessed from a remote location. You can think of it as a gate keeper that blocks access to another Object. (TestATMMachine) The Chain of Responsibility pattern has a group of objects that are expected to between them be able to solve a problem. If the first Object can't solve it, it passes the data to the next Object in the chain. (TestCalcChain) The Interpreter pattern is used to convert one representation of data into another. The context cantains the information that will be interpreted. The expression is an abstract class that defines all the methods needed to perform the different conversions. The terminal or concrete expressions provide specific conversions on different types of data. (MeasurementConversion) The Mediator design pattern is used to handle communication between related objects (Colleagues). All communication is handled by a Mediator Object and the Colleagues don't need to know anything about each other to work together. (TestStockMediator) The Memento design pattern provides a way to store previous states of an Object easily. It has 3 main classes: 1) Memento: The basic object that is stored in different states. 2) Originator: Sets and Gets values from the currently targeted Memento. Creates new Mementos and assigns current values to them. 3) Caretaker: Holds an ArrayList that contains all previous versions of the Memento. It can store and retrieve stored Mementos. (TestMemento) The Visitor design pattern allows you to add methods to classes of different types without much altering to those classes. You can make completely different methods depending on the class used with this pattern. (VisitorTest)
Narasimha1997 /
A tiny library that brings the support of dictionaries to C programming language with a fast lookup using hash tables. dict type can be used to associate large arrays with string keys.
MariamGado0 /
# Starbucks Promotions Project ### This project is the Capstone Project of Udacity's Machine Learning Engineering Nanodegree program.    ## Problem Statement This data set contains simulated data that mimics customer behavior on the Starbucks rewards mobile app. Once every few days, Starbucks sends out an offer to users of the mobile app. An offer can be merely an advertisement for a drink or an actual offer such as a discount or BOGO (buy one get one free). Some users might not receive any offer during certain weeks. Not all users receive the same offer, and that is the challenge to solve with this data set. The task is to combine transaction, demographic and offer data to determine which demographic groups respond best to which offer type. This data set is a simplified version of the real Starbucks app because the underlying simulator only has one product whereas Starbucks actually sells dozens of products. Starbucks collects the customer data to understand their behaviour on the rewards and offers sent via the mobile-app. Once every few days, Starbucks sends the personalised offers to its customers. These customers can respond positively/negatively/neutrally. A key thing to note is that not all the customers receive the same offer. The task of this project is to combine transaction, demographic and offer data of the past (which is already provided) to determine which demographic groups respond best to which offer types. In order to develop this project, we needed to use some tools, packages, systems and services that could help us achieve our goals. #### Libraries First of all, we used **Python** to write our scripts not only for algorithm training and serving but also for the orchestration of the whole process. Important packages within this environment are listed below: This project is developed in Python 3.6. You will need install some libraries in order to run the code. Libraries are: * `pandas` so we could work with tabular data in dataframes; * `Ploty` so we could visualize our Dataset; * `matplotlib` for Dataset visualization; * `numpy` so we could easily manipulate arrays and data structures; * `seaborn` and `matplotlib` so we could generate insightful visualizations; * `sklearn` so we could build and develop our model pipeline; * `imblearn` so we could apply SMOTE to our training data; * `xgboost` so we could have our main classifier; * `sagemaker` so we could easily interact with AWS. * `json` for reading our Dataset Files. * `boto3` Finally, we used AWS environment in order to launch training jobs, deploy our model and serve predictions. The main services used are also listed below: * __AWS SageMaker__: training, hyperparameter tuning and endpoint serving; * __Amazon S3__: saving our data and model artifacts; ## Files Descriptions This project is structured as follows: #### 01. Proposal Project proposal documentation. #### 02. Data_Cleaning_[Dataset] Folder to perform data preparation and Dataset Cleaning and Prepare the Final Data for Further using in model algorithms. #### 03. Pre-processing Dataset Visualization Folder to perform final Pre-processing Dataset to be used in Visualization and exploration. #### 04. Dataset_Visualization Folder to perform Visualizations for the Pre-processed Dataset. #### 06. ORG_Starbucks_Capstone_Project.ipynb Jupyter notebook file that deploy final model and create an endpoint and orchestrates the end-to-end process in AWS SageMaker and also interacts with other services.