Tag:generic paradigm

  • Generic function of typescript


    Official link Write a function where the type of input is related to the type of output, or the types of two inputs are related in some way. Let’s consider a function that returns the first element of the array: function firstElement(arr: any[]) { return arr[0]; } This function does its job, but unfortunately the […]

  • 2021swift parameter and generic parameter reference!


    This section covers generic types, generic functions, and parameters of generic constructors, including formal and arguments. When declaring a generic type, function, or constructor, you must specify the corresponding type parameters. A type parameter is equivalent to a placeholder. When a generic type is instantiated, a generic function or a generic constructor is called, it […]

  • Protobuf simple type direct deserialization method


    I have an idea. It’s perfect to have a high-performance data protocol specification that can cross platform, enable data to be read between two different programs, and preferably support direct serialization of objects. target Supports arbitrary object serialization Support from similarSystem.StringGet the class information from the string of and deserialize it Support direct serialization and […]

  • There are many ways to pass parameters to action in asp.net core


    Asp.net core is a cross platform, open source, lightweight, high-performance and highly modular web framework. In asp.net core MVC, there are many ways to pass parameters to the action method, such as URL, querystring, request header, request body, form, etc. This article will discuss with you how to use these methods and use code to […]

  • 15 questions on how to use Java generics


    Summary:Java generics is essentially a parameterized type, that is, the operated data type is specified as a parameter (type parameter). This parameter type can be used in the creation of classes, interfaces and methods, which are called generic classes, generic interfaces and generic methods respectively. This article is shared from Huawei cloud community《15 questions to […]

  • Trust state machine design pattern


    What is a state machine State machines are everywhere, such as TCP, HTTP, regexp and so on, which are essentially state machines. A state machine consists of States and transitions between states. Take the traffic light as a simple example. The traffic light will be in three states: red, green and yellow. There are definite […]

  • Asp.net core MVC entry to mastery – 3. Using mediatr


    Asp.net core MVC entry to mastery – 3. Using mediatr Environmental Science: .NET 5 ASP.NET Core MVC (project) 1. MediatR A simple mediator pattern implementation in mediatr. NetIn process messaging mechanism(no other external dependencies). It supports the message transmission of request / response, command, query, notification and event in the form of synchronous or asynchronous, […]

  • Talk about Flink’s internal time service manager


    order This article mainly studies the internal time service manager of Flink InternalTimeServiceManager flink-streaming-java_2.11-1.7.0-sources.jar!/org/apache/flink/streaming/api/operators/InternalTimeServiceManager.java @Internal public class InternalTimeServiceManager<K> { @VisibleForTesting static final String TIMER_STATE_PREFIX = “_timer_state”; @VisibleForTesting static final String PROCESSING_TIMER_PREFIX = TIMER_STATE_PREFIX + “/processing_”; @VisibleForTesting static final String EVENT_TIMER_PREFIX = TIMER_STATE_PREFIX + “/event_”; private final KeyGroupRange localKeyGroupRange; private final KeyContext keyContext; private final PriorityQueueSetFactory […]

  • Rust association type and default generic type parameter


    1、 Associated types When we read the rust program, the following code sometimes appears: trait Iterator { type Item; fn next(&mut self) -> Option<Self::Item>; } Here is the comment of the above code: iterator trait has an association typeItem。ItemIs a placeholder type, and the next method will returnOption<Self::Item>Value of type. thistraitThe implementer of will specifyItemSpecific […]

  • Mybatis single table addition, deletion, modification, query and extraction


    In daily development, we can extract or use mybatis plus for the addition, deletion, modification and query of mybatis single table Extract public Dao interface public interface IBaseDao<T> { int deleteByPrimaryKey(Long id); int insert(T t); int insertSelective(T t); T selectByPrimaryKey(Long id); int updateByPrimaryKeySelective(T t); int updateByPrimaryKey(T t); } Extract public service public interface IBaseService<T> { […]

  • In public projects, I use JSDoc instead of TS


    Public modules are usually used by multiple projects and different developers, so when developing public modules, it’s not enough for you to use them yourself. It’s key to let everyone know how to use them quickly. This is usually done in three ways: Carefully divide the code logic and follow the opening and closing principle; […]

  • The rust lifecycle bound is a reference for generics


    In actual programming, generic reference may occur. We will write the following code: struct Inner<‘a, T> { data: &’a T, } Compilation errors will occur: error[E0309]: the parameter type `T` may not live long enough –> src/main.rs:16:5 | 15 | struct Inner<‘a, T> { | – help: consider adding an explicit lifetime bound `T: ‘a`… […]