repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
KKothuri/Data-Structures | containers/Stack.h | <filename>containers/Stack.h
#ifndef STACK_H
#define STACK_H
#include "XORList.h"
/*
Stack class to mimic STL stack.
*/
template <class Object>
class Stack
{
XORList<Object> elem_;
public:
void push(const Object& x) { elem_.insertFront(x); }
Object top() { if(size()) return elem_[0]; }
void pop() { ... |
KKothuri/Data-Structures | containers/List.h | <gh_stars>0
#ifndef LIST_H
#define LIST_H
#include "Container.h"
#include <utility>
using ull = unsigned long long int;
using namespace std;
/*
List(Doubly Linked) class
*/
template <class Object>
class List : public NodeBasedContainer<Object>
{
protected:
class Node
{
public:
Object data;
Node* left;
No... |
KKothuri/Data-Structures | util/Pair.h | <filename>util/Pair.h
#ifndef PAIR_H
#define PAIR_H
//Pair class to mimic the STL pair class
template <class Obj1, class Obj2>
class Pair
{
public:
Obj1 first;
Obj2 second;
Pair() {};
Pair(const Obj1& f, const Obj2& s) : first(f), second(s) {}
Pair(const Pair& p) : first(p.first), second(p.second) {}
Pair& oper... |
KKothuri/Data-Structures | containers/Queue.h | #ifndef QUEUE_H
#define QUEUE_H
#include "XORList.h"
/*
Queue class to mimic STL queue.
*/
template <class Object>
class Queue
{
XORList<Object> elem_;
public:
void push(const Object& x) { elem_.insertEnd(x); }
Object front() { if(size()) return elem_[0]; }
void pop() { if(size()) elem_.removeFront(... |
KKothuri/Data-Structures | containers/XORList.h | #ifndef XORLIST_H
#define XORLIST_H
#include "Container.h"
#include <utility>
using ull = unsigned long long int;
using namespace std;
/*
XORList(Memory Efficient Doubly Linked List) class
*/
template <class Object>
class XORList : public NodeBasedContainer<Object>
{
protected:
class Node
{
public:
Object da... |
KKothuri/Data-Structures | containers/BinarySearchTree.h | #ifndef BINARYSEARCHTREE_H
#define BINARYSEARCHTREE_H
#include "Container.h"
#include <functional>
#include <algorithm>
template <class Object>
using comparer = std::function<bool(const Object& a, const Object& b)>;
/*
BST class
*/
template <class Object, comparer<Object> comp = [](const Object& a, const Object& b)... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/AugurDatabase.h | #ifndef EMPLOYEE_COMPLETED_AUGUR_DATABASE_H
#define EMPLOYEE_COMPLETED_AUGUR_DATABASE_H
#include "AugurDB.h"
#include "Database.h"
#include <memory>
class AugurDatabase : public Database
{
std::shared_ptr<AugurDB> augur_db{};
public:
AugurDatabase(std::shared_ptr<AugurDB> augur_db);
virtual SaveResult s... |
hoelzl/CleanCodeCppCatch | Employee/Employee.h | <filename>Employee/Employee.h
#ifndef EMPLOYEE_EMPLOYEE_H
#define EMPLOYEE_EMPLOYEE_H
#include "AugurDB.h"
#include "Project.h"
#include <iostream>
#include <memory>
#include <string>
enum class EmployeeType
{
Regular,
Houred,
Commissioned,
};
enum class SaveResult
{
Successful,
Failed,
};
clas... |
hoelzl/CleanCodeCppCatch | Shape/shape.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#include "point.h"
#include <array>
#include <iostream>
class AbstractShape
{
public:
virtual double compute_area() const = 0;
virtual void move(double x, double y) = 0;
protected:
friend std::ostream& operator<<(std::ostream& s,
... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/Project.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#ifndef EMPLOYEE_COMPLETED_PROJECT_H
#define EMPLOYEE_COMPLETED_PROJECT_H
#include <string>
class Project
{
private:
std::string name;
double assets;
double commissioned_pay;
public:
Project(std::string name, double assets, double commissioned_pay);
... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/Employee.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#ifndef EMPLOYEE_COMPLETED_EMPLOYEE_H
#define EMPLOYEE_COMPLETED_EMPLOYEE_H
#include "Database.h"
#include "PaymentScheme.h"
#include "Project.h"
#include "ReportPrinter.h"
#include <memory>
#include <string>
class Employee
{
private:
int id;
std::string name;
... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/AugurDB.h | <filename>EmployeeCompleted/AugurDB.h
# pragma once
#ifndef EMPLOYEE_AUGURDB_H
#define EMPLOYEE_AUGURDB_H
#include <stdexcept>
#include <string>
#include <vector>
struct DatabaseRecord
{
DatabaseRecord(std::vector<std::string> saved_fields)
: saved_fields{std::move(saved_fields)}
{
}
std::ve... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/PaymentScheme.h | <filename>EmployeeCompleted/PaymentScheme.h
#pragma once
#ifndef EMPLOYEE_COMPLETED_PAYMENT_SCHEME
#define EMPLOYEE_COMPLETED_PAYMENT_SCHEME
class Employee;
class Project;
class PaymentScheme
{
public:
virtual int get_regular_hours() const = 0;
virtual int get_overtime_hours() const = 0;
int get_total_hou... |
hoelzl/CleanCodeCppCatch | MemoryAndPolymorphism/cat.h | #pragma once
#include "animal.h"
#include <string>
using namespace std::string_literals;
class Cat : public Animal
{
#if SHOW_ANIMAL_INSTANCE_LIFE_CYCLE
public:
Cat() noexcept
{
std::cout << "Creating cat instance " << std::hex
<< reinterpret_cast<std::uintptr_t>(this)
... |
hoelzl/CleanCodeCppCatch | CleanCode/complex_function.h | #pragma once
#include <string>
std::string format_text(std::string text, std::string header,
std::string footer, std::size_t num_separator_chars);
class FormatText
{
std::string text;
std::string header;
std::string footer;
std::size_t num_separator_chars;
std::size_t min_n... |
hoelzl/CleanCodeCppCatch | PrimeFactorsCompleted/prime_factors.h | #pragma once
#include <vector>
#include <string>
std::vector<long> compute_prime_factors(long n);
std::string format_primes(const std::vector<long>& primes);
void compute_and_write_primes(long n, std::ostream& os); |
hoelzl/CleanCodeCppCatch | MemoryAndPolymorphism/animal.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#include <cstdint>
#include <iostream>
#include <string>
using namespace std::string_literals;
class Animal
{
public:
#if SHOW_ANIMAL_INSTANCE_LIFE_CYCLE
Animal() noexcept
{
std::cout << "Creating animal instance " << std::hex
<< reinte... |
hoelzl/CleanCodeCppCatch | Employee/Project.h | <reponame>hoelzl/CleanCodeCppCatch<filename>Employee/Project.h
#ifndef EMPLOYEE_PROJECT_H
#define EMPLOYEE_PROJECT_H
#include <string>
class Project
{
private:
std::string name{};
double assets{};
double commissioned_pay{};
public:
Project(std::string name, double assets = 20000.0,
double... |
hoelzl/CleanCodeCppCatch | DvdShop/Customer.h | <gh_stars>0
#ifndef DVDSHOP_CUSTOMER_H
#define DVDSHOP_CUSTOMER_H
#include "Rental.h"
#include <string>
#include <vector>
using namespace std::literals::string_literals;
class Customer
{
private:
std::string name;
std::vector<Rental> rentals{};
static std::string to_string(double d);
public:
explici... |
hoelzl/CleanCodeCppCatch | FizzBuzz/fizz_buzz.h | #pragma once
void fizz_buzz(int n);
|
hoelzl/CleanCodeCppCatch | FizzBuzzCompleted/fizz_buzz.h | <gh_stars>0
#pragma once
#include <string>
std::string say_number(int n);
void fizz_buzz(std::ostream& os, int n);
void fizz_buzz(int n);
|
hoelzl/CleanCodeCppCatch | DvdShopCompleted/Movie.h | #ifndef DVDSHOP_MOVIE_H
#define DVDSHOP_MOVIE_H
#include <string>
class Movie
{
private:
std::string title;
public:
explicit Movie(std::string title);
[[nodiscard]] const std::string& get_title() const;
[[nodiscard]] virtual double determine_amount(int days_rented) const = 0;
[[nodiscard]] virtu... |
hoelzl/CleanCodeCppCatch | StackCompleted/stack.h | #pragma once
#include <array>
#include <optional>
#include <vector>
class Stack
{
private:
std::vector<int> elements{};
std::optional<int> default_value{};
public:
[[nodiscard]] bool is_empty() const noexcept;
void push(int element);
int pop();
[[nodiscard]] std::size_t size() const noexcept;
... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/Database.h | #pragma once
#ifndef EMPLOYEE_COMPLETED_DATABASE_H
#define EMPLOYEE_COMPLETED_DATABASE_H
#include "AugurDB.h"
#include <iostream>
using namespace std::string_literals;
class Employee;
enum class SaveResult
{
Successful,
Failed,
};
class Database
{
public:
virtual ~Database() = default;
virtual Sav... |
hoelzl/CleanCodeCppCatch | Ox/game.h | #pragma once
#include <string>
class Dictionary
{
public:
virtual ~Dictionary() = default;
virtual std::string get_random_word() = 0;
};
enum class GameState
{
NotStarted,
InProgress,
Won,
Lost
};
|
hoelzl/CleanCodeCppCatch | DvdShopCompleted/ChildrensMovie.h | #ifndef DVDSHOP_CHILDRENSMOVIE_H
#define DVDSHOP_CHILDRENSMOVIE_H
#include "Movie.h"
class ChildrensMovie : public Movie
{
public:
ChildrensMovie(const std::string& title);
double determine_amount(int days_rented) const override;
int determine_points(int days_rented) const override;
};
#endif//DVDSHOP_C... |
hoelzl/CleanCodeCppCatch | PointCompleted/encapsulated_point.h | #pragma once
#include <iostream>
class EncapsulatedPoint
{
private:
double x;
double y;
EncapsulatedPoint(double x, double y)
{
this->x = x;
this->y = y;
}
public:
static EncapsulatedPoint from_cartesian(double x, double y)
{
return {x, y};
}
static Encapsu... |
hoelzl/CleanCodeCppCatch | LoadBalancer/controller.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#include "load_balancer.h"
class Controller {
private:
LoadBalancer load_balancer{};
Algorithm algorithm;
public:
void balance();
void set_algorithm(Algorithm algorithm);
};
|
hoelzl/CleanCodeCppCatch | DvdShopCompleted/RentalStatement.h | <reponame>hoelzl/CleanCodeCppCatch<filename>DvdShopCompleted/RentalStatement.h
#ifndef DVDSHOP_RENTALSTATEMENT_H
#define DVDSHOP_RENTALSTATEMENT_H
#include "Rental.h"
#include <string>
#include <vector>
class RentalStatement
{
private:
std::string customer_name;
std::vector<Rental> rentals{};
double total... |
hoelzl/CleanCodeCppCatch | LoadBalancerCompleted/controller.h | <gh_stars>0
#pragma once
#include "load_balancer.h"
#include <memory>
class Controller {
private:
std::unique_ptr<LoadBalancer> load_balancer{};
public:
void balance();
void set_load_balancer(std::unique_ptr<LoadBalancer> load_balancer);
};
|
hoelzl/CleanCodeCppCatch | Ox/core.h | <filename>Ox/core.h
#ifndef OX_CORE_H
#define OX_CORE_H
#include <memory>
#include <string>
#include <vector>
class CharacterMatch
{
protected:
char proposed_char{};
public:
explicit CharacterMatch(char proposed_char);
[[nodiscard]] virtual bool is_perfect_match() const = 0;
[[nodiscard]] virtual boo... |
hoelzl/CleanCodeCppCatch | MemoryAndPolymorphism/dog.h | #pragma once
#include "animal.h"
#include <string>
using namespace std::string_literals;
class Dog : public Animal
{
#if SHOW_ANIMAL_INSTANCE_LIFE_CYCLE
public:
Dog() noexcept
{
std::cout << "Creating dog instance " << std::hex
<< reinterpret_cast<std::uintptr_t>(this)
... |
hoelzl/CleanCodeCppCatch | PointCompleted/raw_point.h | <filename>PointCompleted/raw_point.h
#pragma once
#include <iostream>
struct RawPoint {
double x;
double y;
};
inline RawPoint point_from_polar(double r, double theta)
{
return {r * cos(theta), r * sin(theta)};
}
inline double point_r(RawPoint point)
{
return sqrt(point.x * point.x + point.y * point.... |
hoelzl/CleanCodeCppCatch | DvdShop/Rental.h | #ifndef DVDSHOP_RENTAL_H
#define DVDSHOP_RENTAL_H
#include "Movie.h"
class Rental
{
private:
Movie movie;
int days_rented;
public:
Rental(const Movie& movie, int days_rented);
[[nodiscard]] const Movie& get_movie() const;
[[nodiscard]] int get_days_rented() const;
};
#endif//DVDSHOP_RENTAL_H
|
hoelzl/CleanCodeCppCatch | LoadBalancer/resource.h | #pragma once
#include <string>
#include <iostream>
class Resource
{
std::string description;
public:
Resource(std::string description) : description(description)
{
}
std::string get_description() const
{
return description;
}
};
inline std::ostream& operator<<(std::ostream& s, c... |
hoelzl/CleanCodeCppCatch | DvdShopCompleted/RegularMovie.h | #ifndef DVDSHOP_REGULARMOVIE_H
#define DVDSHOP_REGULARMOVIE_H
#include "Movie.h"
class RegularMovie : public Movie
{
public:
RegularMovie(const std::string& title);
double determine_amount(int days_rented) const override;
int determine_points(int days_rented) const override;
};
#endif//DVDSHOP_REGULARMO... |
hoelzl/CleanCodeCppCatch | Workshops/salaries_completed.h | #include <string>
#include <vector>
double process_salary(int day_number, double salary_per_day,
const char* employee_name,
std::vector<double>& all_salaries);
double compute_salary_after_taxes(int day_number, double salary_per_day);
double compute_salary_before_taxes(int ... |
hoelzl/CleanCodeCppCatch | LoadBalancerCompleted/resource.h | #pragma once
#include <cstdint>
#include <iostream>
#include <string>
#define SHOW_RESOURCE_LIFECYCLE 1
class Resource
{
std::string description;
public:
Resource(std::string description) : description(description)
{
#if SHOW_RESOURCE_LIFECYCLE
std::cout << "Creating resource " << std::hex
... |
hoelzl/CleanCodeCppCatch | LoadBalancerCompleted/load_balancer.h | <reponame>hoelzl/CleanCodeCppCatch
#pragma once
#include "resource.h"
#include <iostream>
#include <vector>
using queue_t = std::vector<Resource>;
class LoadBalancer
{
public:
virtual ~LoadBalancer() = default;
virtual void add_resource(Resource r) = 0;
virtual void balance() = 0;
};
class RoundRobin : ... |
hoelzl/CleanCodeCppCatch | EmployeeCompleted/ReportPrinter.h | #pragma once
#include <iostream>
#include <string>
class Employee;
class ReportPrinter
{
std::ostream& os;
public:
explicit ReportPrinter(std::ostream& os = std::cout) : os{os}
{
}
virtual ~ReportPrinter() = default;
virtual void print_report(const Employee& employee) const;
}; |
hoelzl/CleanCodeCppCatch | DvdShop/Movie.h | #ifndef DVDSHOP_MOVIE_H
#define DVDSHOP_MOVIE_H
#include <string>
class Movie
{
private:
std::string title;
int price_code;
public:
static constexpr int CHILDRENS{2};
static constexpr int REGULAR{0};
static constexpr int NEW_RELEASE{1};
Movie(const std::string& title, int price_code);
[[... |
hoelzl/CleanCodeCppCatch | MemoryAndPolymorphism/print_memory_layout.h | <reponame>hoelzl/CleanCodeCppCatch<gh_stars>0
#pragma once
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
template <typename T>
void print_address(const std::string& prefix, T obj)
{
std::cout << prefix << " Ox" << std::hex
<< reinterpret_cast<std::uintptr_t>(obj) << std:... |
hoelzl/CleanCodeCppCatch | LoadBalancer/load_balancer.h | <filename>LoadBalancer/load_balancer.h
#pragma once
#include "resource.h"
#include <vector>
#include <utility>
enum class Algorithm
{
ROUND_ROBIN,
WEIGHTED_ROUND_ROBIN
};
using queue_t = std::vector<Resource>;
class LoadBalancer {
public:
// For RR scheduling
queue_t queue{};
// For Weighted RR ... |
hoelzl/CleanCodeCppCatch | MemoryAndPolymorphism/polymorphic_array.h | #pragma once
#include <array>
#include <iostream>
#include <memory>
#include <span>
#include <typeinfo>
#include <vector>
#define USE_TEMPLATES 1
struct MyBase {
explicit MyBase(int x) : x{x}
{
}
int x;
MyBase& inc()
{
x += 1;
return *this;
}
};
struct MyDerived : p... |
hoelzl/CleanCodeCppCatch | Workshops/salaries_workshop.h | #include <vector>
double handle_money_stuff(int i_dow, double d_spd, const char* pc_n,
std::vector<double>& dv_slrs);
|
uzvermode/libinput | src/evdev-mt-touchpad.c | <filename>src/evdev-mt-touchpad.c
/*
* Copyright © 2014-2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the righ... |
alexandremagro/tspga | tsplib.h | <reponame>alexandremagro/tspga
#ifndef TSPLIB_H_INCLUDED
#define TSPLIB_H_INCLUDED
typedef struct {
char name[256], edge_weight_type[256], edge_weight_format[256];
int size;
double **cost_matrix;
Point *points;
} Map;
void free_map(Map *map);
Map read_tsp_lib(char *file_name);
#endif |
alexandremagro/tspga | genetic.h | #ifndef GENETIC_H_INCLUDED
#define GENETIC_H_INCLUDED
typedef struct {
double distance, fitness;
Map *map;
Point **points;
} Tour;
typedef struct {
int size;
Tour *tours;
Tour *fittest;
} Population;
Population alloc_population(int size);
void free_population(Population *population);
Population ga(Map *c... |
alexandremagro/tspga | point.h | #ifndef POINT_H_INCLUDED
#define POINT_H_INCLUDED
typedef struct {
int id;
float x, y;
} Point;
#endif |
alexandremagro/tspga | tsplib.c | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "point.h"
#include "tsplib.h"
void free_map(Map *map) {
for (int i = 0; i < map->size; i++) {
free(map->cost_matrix[i]);
}
free(map->cost_matrix);
free(map->points);
}
Map read_t... |
alexandremagro/tspga | genetic.c | <reponame>alexandremagro/tspga
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include "point.h"
#include "tsplib.h"
#include "genetic.h"
// Rand a number from 0 to 1
static float rand_prob() {
return (float) rand() / (RAND_MAX);
}
// Rand a number from min to (... |
alexandremagro/tspga | main.c | <reponame>alexandremagro/tspga
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include "point.h"
#include "tsplib.h"
#include "genetic.h"
/* PRINTS */
void plot_tour(Tour *tour) {
for (int i = 0; i < tour->map->size; i++) {
printf("%d,%.2f,%.2f ", tour->points... |
everlyy/gamesneeze | src/discord/DiscordRpc.h | <gh_stars>1-10
#pragma once
#include <discord_register.h>
#include <discord_rpc.h>
class Discord {
public:
static void Initialise();
static void Update();
static void Stop();
};
|
Neteroh/FinalLevelRenderer | MasteryAssignments/Turn in Folder M1/renderer.h | <reponame>Neteroh/FinalLevelRenderer
// minimalistic code to draw a single triangle, this is not part of the API.
#include "shaderc/shaderc.h" // needed for compiling shaders at runtime
#include <vector>
#include <cstdlib>
#include <ctime>
#ifdef _WIN32 // must use MT platform DLL libraries on windows
#pragma comment(l... |
Neteroh/FinalLevelRenderer | TurnInFolder/h2bParser.h | <reponame>Neteroh/FinalLevelRenderer
#ifndef _H2BPARSER_H_
#define _H2BPARSER_H_
#include <fstream>
#include <vector>
#include <set>
namespace H2B {
#pragma pack(push,1)
struct VECTOR {
float x, y, z;
};
struct VERTEX {
VECTOR pos, uvw, nrm;
};
struct alignas(void*) ATTRIBUTES {
VECTOR Kd; float d;
V... |
Neteroh/FinalLevelRenderer | MasteryAssignments/Turn in Folder M2/renderer.h | // minimalistic code to draw a single triangle, this is not part of the API.
#include "shaderc/shaderc.h" // needed for compiling shaders at runtime
#ifdef _WIN32 // must use MT platform DLL libraries on windows
#pragma comment(lib, "shaderc_combined.lib")
#endif
// Simple Vertex Shader
const char* vertexShaderSource ... |
Neteroh/FinalLevelRenderer | TurnInFolder/renderer.h | // minimalistic code to draw a single triangle, this is not part of the API.
// TODO: Part 1b
#include "FSLogo.h"
#include <fstream>
#include <string>
#include <vector>
#include "shaderc/shaderc.h" // needed for compiling shaders at runtime
#ifdef _WIN32 // must use MT platform DLL libraries on windows
#pragma comment(... |
hairyhenderson/GarageMonitor | MorseDictionary.h | #ifndef MorseDictionary_h
#define MorseDictionary_h
// A table of the standard ASCII table with Morse code equivalents.
const char* lookup(char ch) {
switch (ch) {
case 'A':
return ".-";
case 'B':
return "-...";
case 'C':
return "-.-.";
case 'D':
return "-..";
case 'E':
return ".";
ca... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strdel.c | #include "libft.h"
void ft_strdel(char **str)
{
if (*str && str)
{
free(*str);
*str = NULL;
}
}
|
natflausino/cub3D | libraries/libft/srcs/libft/ft_strchr.c | #include "libft.h"
char *ft_strchr(const char *s, int c)
{
int i;
char *tmp;
i = 0;
tmp = (char *)s;
if (!s)
return (NULL);
if (c == '\0')
{
while (*tmp)
tmp++;
return ((char *) tmp);
}
while (tmp[i] != '\0')
{
if (tmp[i] == (char)c)
return ((char *)&tmp[i]);
i++;
}
if (*tmp == '\0'... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_split.c | #include "libft.h"
static void bad_spot(char **tab, int i)
{
while (i)
{
free(tab[i]);
i--;
}
free(tab);
}
int c_split(char const *str, char c)
{
int i;
int cp_word;
int is_num;
is_num = 0;
cp_word = 0;
i = 0;
while (str[i])
{
if (str[i] == c)
is_num = 0;
else
{
if (is_num == 0)
{
... |
natflausino/cub3D | src/bonus/render_life_bonus.c | #include "../../includes/bonus/cub3d_bonus.h"
void render_lifebar(t_game *game)
{
int color;
game->pos.x = game->file.width - 153;
game->pos_life.x = 163;
while (game->pos.x < game->file.width)
{
game->pos.y = 0;
game->pos_life.y = 0;
while (game->pos.y < 80)
{
color = get_color_life(&game->life_tex[g... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strsub.c | <filename>libraries/libft/srcs/libft/ft_strsub.c
#include "libft.h"
char *ft_strsub(char *str, int start, int len)
{
int i;
char *output;
i = 0;
if (!str)
return (NULL);
output = ft_calloc(1, sizeof(char) * (len + 1));
if (!output)
return (NULL);
while (i < len && (str[start + i] != '\n'))
{
outp... |
natflausino/cub3D | src/mandatory/parsing_map2.c | #include "../../includes/mandatory/cub3d.h"
void inside_map(char **tab)
{
int i;
int j;
i = 0;
while (tab[i])
{
j = 0;
while (tab[i][j])
{
if (tab[i][j] != '1' && tab[i][j] != '2' &&
tab[i][j] != '0' && tab[i][j] != ' ' && tab[i][j] != 'N' &&
tab[i][j] != 'S' && tab[i][j] != 'W' && tab[i][j] != 'E... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_itoa.c | <gh_stars>1-10
#include "libft.h"
static int itoa_isnegative(int number)
{
if (number < 0)
{
return (1);
}
else
{
return (0);
}
}
static int itoa_countdigit(unsigned int number)
{
size_t digits;
if (number == 0)
{
return (1);
}
digits = 0;
while (number >= 1)
{
number /= 10;
digits++;
}
retu... |
natflausino/cub3D | includes/bonus/structs_bonus.h | #ifndef STRUCTS_BONUS_H
# define STRUCTS_BONUS_H
# include "cub3d_bonus.h"
typedef struct s_file
{
int width;
int height;
char *no_path;
char *so_path;
char *we_path;
char *ea_path;
char *d_path;
char *f_path;
int color_floor;
int color_ceiling;
int map_col;
int map_row;
char **tab;
int player_fo... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strclen.c | #include "libft.h"
size_t ft_strclen(const char *str, const char c)
{
unsigned int i;
i = 0;
while (str[i] && str[i] != c)
i++;
return (i);
}
|
natflausino/cub3D | libraries/libft/srcs/libft/ft_strdup.c | <gh_stars>1-10
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *output;
int i;
int size;
if (!s1)
return (NULL);
size = ft_strlen(s1);
output = ft_calloc(1, sizeof(char) * (size + 1));
if (!output)
return (NULL);
i = 0;
while ((char)s1[i])
{
output[i] = s1[i];
i++;
}
output[i]... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_substr.c | #include "libft.h"
static char *ft_strnew(size_t size)
{
char *s;
size++;
s = (char *)ft_calloc(1, sizeof(char) * size);
if (!s)
return (NULL);
ft_bzero(s, size);
return (s);
}
char *ft_substr(char const *s, unsigned int start, size_t len)
{
if (start >= ft_strlen(s))
return (ft_strnew(0));
if (ft_strlen... |
natflausino/cub3D | src/mandatory/sprites.c | <reponame>natflausino/cub3D<gh_stars>1-10
#include "../../includes/mandatory/cub3d.h"
void sprite_height(t_game *game, int *start, int *end, int *i)
{
if (*end - *start >= game->file.height)
{
*i += -(*start);
*start = 0;
*end = game->file.height;
}
}
void draw_sprite(t_game *game, int x, int s_pos, int sp)
... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strlen.c | #include "libft.h"
size_t ft_strlen(const char *s)
{
size_t i;
if (!s)
return (0);
i = 0;
while (s[i] != 0)
i++;
return (i);
}
|
natflausino/cub3D | src/bonus/events_bonus.c | <gh_stars>1-10
#include "../../includes/bonus/cub3d_bonus.h"
int close_window(t_game *game)
{
free_sprites(game);
game->sprite = NULL;
free_textures(game);
free_life(game);
free_item(game);
free_weapon(game);
free(game->tex);
game->tex = NULL;
free(game->ray.dist_wall);
game->ray.dist_wall = NULL;
table_fre... |
natflausino/cub3D | src/bonus/get_param_bonus.c | <reponame>natflausino/cub3D<filename>src/bonus/get_param_bonus.c<gh_stars>1-10
#include "../../includes/bonus/cub3d_bonus.h"
int check_digit(char *tab, char *set)
{
int i;
int j;
int flag;
i = 0;
if (!tab || !*tab || !set)
return (0);
while (tab[i])
{
flag = 0;
j = 0;
while (set[j])
{
if (tab[i] =... |
natflausino/cub3D | src/mandatory/error.c | #include "../../includes/mandatory/cub3d.h"
void print_error_1(int err)
{
if (err == -10)
ft_putendl("Error\nFile must have .cub extension.\n");
if (err == -11)
ft_putendl("Error\nInvalid file .cub.\n");
if (err == -12)
ft_putendl("Error\nTry cub3D <file>.cub --save(optional).\n");
if (err == -13)
ft_puten... |
natflausino/cub3D | src/bonus/render_item_bonus.c | #include "../../includes/bonus/cub3d_bonus.h"
void render_item(t_game *game)
{
int color;
game->pos.x = game->file.width - 153;
game->pos_item.x = 163;
while (game->pos.x < game->file.width)
{
game->pos.y = 80;
game->pos_item.y = 0;
while (game->pos.y < 160)
{
color = get_color_item(&game->item_tex[ga... |
natflausino/cub3D | includes/bonus/cub3d_bonus.h | <reponame>natflausino/cub3D<gh_stars>1-10
#ifndef CUB3D_BONUS_H
# define CUB3D_BONUS_H
/******************************************************************************
** LIBRARIES
******************************************************************************/
# include <math.h>
# include <stdio.h>
# include <float.h>
... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_calloc.c | <filename>libraries/libft/srcs/libft/ft_calloc.c
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
size_t total_size;
void *dest;
total_size = size * count;
dest = malloc(total_size);
if (!dest)
return (0);
ft_memset(dest, 0, total_size);
return (dest);
}
|
natflausino/cub3D | src/bonus/free_textures_bonus.c | <reponame>natflausino/cub3D
#include "../../includes/bonus/cub3d_bonus.h"
void free_textures(t_game *game)
{
if (game->file.no_path)
{
mlx_destroy_image(game->data.mlx, game->tex[N_TEX].img);
free(game->file.no_path);
game->file.no_path = NULL;
}
if (game->file.so_path)
{
mlx_destroy_image(game->data.mlx,... |
natflausino/cub3D | src/mandatory/graphics.c | #include "../../includes/mandatory/cub3d.h"
void draw(t_game *game)
{
cast_all_rays(game);
if (game->init == 1)
{
image_create(game);
exit(0);
}
}
void screen_resolution(t_game *game)
{
int max_w;
int max_h;
mlx_get_screen_size(game->data.mlx, &max_w, &max_h);
if (game->file.width > max_w)
game->file... |
natflausino/cub3D | src/bonus/textures_bonus.c | #include "../../includes/bonus/cub3d_bonus.h"
void texture_select(t_game *game)
{
if (game->ray.was_hit_v == 0 && game->ray.face_up)
game->tex[WALL].addr = (int *)mlx_get_data_addr(game->tex[S_TEX].img,
&game->tex[S_TEX].bpp, &game->tex[S_TEX].l_len,
&game->tex[S_TEX].endian);
if (game->ray.was_hit_v == 0 ... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strjoin_free.c | #include "libft.h"
char *ft_strjoin_free(char *s1, char *s2)
{
char *tmp;
tmp = ft_strdup(s1);
free(s1);
s1 = ft_strjoin(s2, tmp);
free(tmp);
free(s2);
s2 = NULL;
return (s1);
}
|
natflausino/cub3D | src/bonus/sprites_utils_bonus.c | <gh_stars>1-10
#include "../../includes/bonus/cub3d_bonus.h"
void find_sprite_2_aux(t_game *game, int i, int j)
{
if (game->weapon == 0 && game->item != 6)
{
if (game->life > 0)
game->life--;
game->sprite->damage = 0;
game->file.tab[i][j] = '0';
game->num_sprite--;
}
else if (game->weapon == 1 && game->... |
natflausino/cub3D | src/bonus/sprites2_bonus.c | <filename>src/bonus/sprites2_bonus.c<gh_stars>1-10
#include "../../includes/bonus/cub3d_bonus.h"
void sort_sprite(t_game *game)
{
int i;
t_sprite temp;
i = 0;
while (++i < game->num_sprite - 1)
{
if (game->sprite[i].dist < game->sprite[i + 1].dist)
{
temp = game->sprite[i];
game->sprite[i] = game->sp... |
natflausino/cub3D | src/bonus/cub3d_bonus.c | #include "../../includes/bonus/cub3d_bonus.h"
void check_paths(t_game *game)
{
if (!game->file.map_row)
{
return_error(-17);
}
if (!game->file.so_path || !game->file.d_path || !game->file.we_path
|| !game->file.no_path || !game->file.ea_path || !game->file.f_path)
{
free_textures(game);
return_error(-21);... |
natflausino/cub3D | includes/bonus/defines_bonus.h | <gh_stars>1-10
#ifndef DEFINES_BONUS_H
# define DEFINES_BONUS_H
# include "cub3d_bonus.h"
/******************************************************************************
** LINUX SCRIPT KEYCODES
******************************************************************************/
# define KEYPRESS 2
# define KEYRELEASE 3
#... |
natflausino/cub3D | includes/mandatory/structs.h | #ifndef STRUCTS_H
# define STRUCTS_H
# include "cub3d.h"
typedef struct s_file
{
int width;
int height;
char *no_path;
char *so_path;
char *we_path;
char *ea_path;
char *s_path;
int color_floor;
int color_ceiling;
int map_col;
int map_row;
char **tab;
int player_found;
int args;
} t_file;
ty... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_atoi.c | #include "libft.h"
int ft_atoi(const char *str)
{
int c;
int s;
int res;
c = 0;
s = 1;
res = 0;
while (str[c] == ' ' || str[c] == '\n' || str[c] == '\t'
|| str[c] == '\v' || str[c] == '\f' || str[c] == '\r')
c++;
if (str[c] == '-' || str[c] == '+')
{
if (str[c] == '-')
s = -1;
c++;
}
while (str[... |
natflausino/cub3D | includes/mandatory/defines.h | <filename>includes/mandatory/defines.h
#ifndef DEFINES_H
# define DEFINES_H
# include "cub3d.h"
/******************************************************************************
** LINUX SCRIPT KEYCODES
******************************************************************************/
# define KEYPRESS 2
# define KEYRELEA... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_putendl.c | #include "libft.h"
void ft_putendl(char *s)
{
if (s != NULL)
{
ft_putstr(s);
ft_putchar('\n');
}
}
|
natflausino/cub3D | libraries/libft/srcs/libft/ft_strlen_pointer.c | #include "libft.h"
int ft_strlen_ptr(char **s)
{
int i;
i = 0;
while (s[i] != NULL)
i++;
return (i);
}
|
natflausino/cub3D | src/bonus/parsing_color_bonus.c | <gh_stars>1-10
#include "../../includes/bonus/cub3d_bonus.h"
void check_color(char **tab)
{
int i;
char *str;
i = 0;
while (i < 3)
{
str = ft_strtrim(tab[i], " ");
if (!check_digit(str, "0123456789"))
{
free(str);
return_free_error(-24, tab);
}
i++;
free(str);
}
}
int color_assemble(int red,... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_bzero.c | #include "libft.h"
void ft_bzero(void *s, size_t n)
{
ft_memset(s, '\0', n);
}
|
natflausino/cub3D | libraries/libft/srcs/libft/ft_strstr.c | #include "libft.h"
int check(int i, char *src, char *to_find);
char *ft_strstr(char *str, char *to_find)
{
int i;
i = 0;
if (to_find[i] == 0)
{
return (str);
}
while (str[i] != '\0')
{
if (str[i] == to_find[0])
{
if (check(i, str, to_find))
{
return (&str[i]);
}
}
i++;
}
return (NULL)... |
natflausino/cub3D | src/bonus/sprites_init_bonus.c | <reponame>natflausino/cub3D
#include "../../includes/bonus/cub3d_bonus.h"
void find_sprite_init(t_game *game)
{
int i;
int j;
int k;
i = -1;
k = 0;
while (++i < game->file.map_row)
{
j = -1;
while (++j < game->file.map_col)
{
if (game->file.tab[i][j] >= '2' && game->file.tab[i][j] <= '6')
find_spr... |
natflausino/cub3D | src/bonus/render_weapon_bonus.c | <reponame>natflausino/cub3D
#include "../../includes/bonus/cub3d_bonus.h"
void render_weapon(t_game *game)
{
int color;
game->pos.x = game->file.width - (game->file.width / 1.8);
game->pos_weapon.x = game->file.width - (game->file.width / 1.3);
while (game->pos.x < (game->file.width - (game->file.width / 3)))
{
... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strjoin.c | <filename>libraries/libft/srcs/libft/ft_strjoin.c
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
unsigned long i;
char *output;
unsigned long size1;
unsigned long size2;
if (!(s1 && s2))
return (NULL);
size1 = ft_strlen(s1);
size2 = ft_strlen(s2);
output = ft_calloc(1, sizeof(ch... |
natflausino/cub3D | src/bonus/raycasting2_bonus.c | <filename>src/bonus/raycasting2_bonus.c
#include "../../includes/bonus/cub3d_bonus.h"
void check_vert(t_game *game, int *verthit)
{
double next_x;
double next_y;
next_x = game->ray.interc_x;
next_y = game->ray.interc_y;
while (next_x >= 0 && next_x < (game->block * game->file.map_col)
&& next_y >= 0 && next_y ... |
natflausino/cub3D | src/bonus/raycasting3_bonus.c | #include "../../includes/bonus/cub3d_bonus.h"
void check_horiz(t_game *game, int *horzhit)
{
double next_x;
double next_y;
next_x = game->ray.interc_x;
next_y = game->ray.interc_y;
while (next_x >= 0 && next_x < (game->block * game->file.map_col)
&& next_y >= 0 && next_y < (game->block * game->file.map_row))
... |
natflausino/cub3D | src/mandatory/textures.c | #include "../../includes/mandatory/cub3d.h"
void texture_select(t_game *game)
{
if (game->ray.was_hit_v == 0 && game->ray.face_up)
game->tex[WALL].addr = (int *)mlx_get_data_addr(game->tex[S_TEX].img,
&game->tex[S_TEX].bpp, &game->tex[S_TEX].l_len,
&game->tex[S_TEX].endian);
if (game->ray.was_hit_v == 0 &&... |
natflausino/cub3D | libraries/libft/srcs/libft/ft_strndup.c | #include "libft.h"
char *ft_strndup(const char *str, size_t n)
{
char *temp;
temp = (char *)ft_calloc(1, sizeof(char) * n + 1);
if (temp == NULL)
return (NULL);
else
ft_strlcpy(temp, str, n + 1);
return (temp);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.