This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
фывс фысфывсфывс фыс фывс ывам ывам ывам ывам ы вам |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
в код вектора з заняття https://gist.github.com/sunmeat/e1888d2d87ad112e3716809c22d467a7 | |
// додати методи: | |
// RemoveFromFront() - метод видаляє значення по індексу 0 | |
// Insert(value, index) - метод який вставляє значення по індексу без втрати елемента по індексу | |
// RemoveByIndex(index) - метод видаляє елемент по індесу | |
// RemoveByValue(value) - метод видаляє всі вказані значення з масиву | |
// Sort() - метод сортує масив за зростанням | |
// Reverse() - метод змінює порядок слідуання елементів на протилежний | |
// Shuffle() - метод випадковим чином перемішує елементи в масиві |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
#include <algorithm> | |
using namespace std; | |
class Vector { | |
unsigned int capacity = 10; // при створенні масиву, він одразу для себе робить запас пам'яті на 10 елементів | |
int* data = new int[capacity]; | |
unsigned int length = 0; // фактична (реальна) кількість елементів, присутніх у масиві |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
використавши саме приклад з уроку за посиланням https://gist.github.com/sunmeat/74becfb24bd3d64314f3bb5e5deb15dd | |
переписати в класі наступні методи: | |
- RemoveFromBack | |
- Print (додати інформацію про ленс та кепесіті) | |
- конструктор копіювання | |
дописати наступні методи: | |
- RemoveFromFront(); // видаляє елемент з початку динамічного масиву | |
- Insert(value, index); // вставляє нове значення по вказанному індексу (з перевіркою на вихід за межі масиву, існуючий по цьому індексу елемент не має переписуватися) | |
- RemoveByIndex(index); // видалити один елемент по вказаному індексу (з перевіркою на вихід за межі масиву та присутність там елементів взагалі) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
#include <algorithm> | |
using namespace std; | |
class Array { | |
unsigned int capacity = 10; // при створенні масиву, він одразу для себе робить запас пам'яті на 10 елементів | |
int* data = new int[capacity]; | |
unsigned int length = 0; // фактична (реальна) кількість елементів, присутніх у масиві |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect} from 'react'; | |
import {atom, useAtom, Provider} from 'jotai'; | |
import './App.css'; // npm install jotai | |
// атомы для хранения состояния | |
const productsAtom = atom([]); // список доступных товаров | |
const cartItemsAtom = atom([]); // товары в корзине | |
const statusAtom = atom('idle'); // статус загрузки (idle, loading, succeeded, failed) | |
const errorAtom = atom(null); // сообщение об ошибке | |
const searchQueryAtom = atom(''); // поисковый запрос |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
import { create } from 'zustand'; // npm install zustand | |
import './App.css'; | |
// создание zustand store для управления корзиной и товарами | |
const useStore = create((set, get) => ({ | |
products: [], // список доступных товаров | |
cartItems: [], // товары в корзине | |
status: 'idle', // статус загрузки (idle, loading, succeeded, failed) | |
error: null, // сообщение об ошибке |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import {useSelector, useDispatch, Provider} from 'react-redux'; | |
import {configureStore, createSlice} from '@reduxjs/toolkit'; | |
import {useState, useEffect} from 'react'; | |
import './App.css'; | |
// действия для асинхронного поиска товаров с использованием redux-thunk | |
export const fetchProducts = (searchQuery = '') => async (dispatch) => { | |
dispatch(setStatus('loading')); // установка статуса загрузки |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
// импортируем хуки и компонент Provider из react-redux | |
import {useSelector, useDispatch, Provider} from 'react-redux' | |
// !!! npm install react-redux @reduxjs/toolkit !!! | |
// хук useSelector позволяет получить доступ к состоянию хранилища - единственного центра данных для всего приложения | |
// в хранилище (store) обычно лежит один большой объект — дерево состояния, для всего | |
// useSelector "селектит" (выбирает) нужный кусок данных из этого глобального состояния |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.jsx: | |
import {useSelector, useDispatch, Provider} from 'react-redux'; | |
import {configureStore, createSlice, createAsyncThunk} from '@reduxjs/toolkit'; | |
import {useState} from 'react'; | |
import './App.css'; | |
// создание асинхронного thunk для имитации логина | |
export const loginUser = createAsyncThunk( | |
'auth/loginUser', // имя действия |
NewerOlder