flow

Paging 3.0 list with new params in Kotlin

五迷三道 提交于 2021-01-24 08:34:18
问题 I have the following code: val history: Flow<PagingData<Any>> = Pager(PagingConfig(pageSize = 10)) { PaginationBaseDataSource(apiService) }.flow .cachedIn(viewModelScope) This currently is displaying a list of items without any additional params. This works Ok... But now I wish to query this list based in certain params that the user can change in frontend, let´s say I wish to add the parameter 3 as a query. val history: Flow<PagingData<Any>> = Pager(PagingConfig(pageSize = 10)) {

Paging 3.0 list with new params in Kotlin

元气小坏坏 提交于 2021-01-24 08:34:07
问题 I have the following code: val history: Flow<PagingData<Any>> = Pager(PagingConfig(pageSize = 10)) { PaginationBaseDataSource(apiService) }.flow .cachedIn(viewModelScope) This currently is displaying a list of items without any additional params. This works Ok... But now I wish to query this list based in certain params that the user can change in frontend, let´s say I wish to add the parameter 3 as a query. val history: Flow<PagingData<Any>> = Pager(PagingConfig(pageSize = 10)) {

How to get process or port Network bandwidth usage in linux

怎甘沉沦 提交于 2021-01-05 12:06:13
问题 I want to get network bandwidth usage for each process. I have found a lot of information about this, such as iftop, nethogs, linux process explorer... But all of them get process brandwidth usage by capture packet(libpcap), by my test in linux it consume a lot of cpu(%10-%15) and the speed of flow is 11MByte/s. If I can get flow rate for each port I can solve this questions because I hava get the table about process port used. So I want to know is there any other way to get port flow without

Type alias in flow with brackets and ellipsis

本小妞迷上赌 提交于 2020-06-28 05:47:40
问题 type WeirdCustomType = {[int]: boolean, ...}; What kind of structure is WeirdCustomType ? Is it simply an array of {int:boolean} types ? (ie, key is an int, value is a boolean)? If so, what is the meaning of ... here? And where can I read about this particular type aliasing usage? 回答1: WeirdCustomType is an “Explicit inexact object type” Its properties consist of: A) properties with integer keys with boolean values the brackets around int indicate that we’re referring to the property keys,

Type alias in flow with brackets and ellipsis

杀马特。学长 韩版系。学妹 提交于 2020-06-28 05:47:27
问题 type WeirdCustomType = {[int]: boolean, ...}; What kind of structure is WeirdCustomType ? Is it simply an array of {int:boolean} types ? (ie, key is an int, value is a boolean)? If so, what is the meaning of ... here? And where can I read about this particular type aliasing usage? 回答1: WeirdCustomType is an “Explicit inexact object type” Its properties consist of: A) properties with integer keys with boolean values the brackets around int indicate that we’re referring to the property keys,

[CTSC2009]移民站选址

爱⌒轻易说出口 提交于 2020-04-08 11:44:24
题意 做法 结论1 :新地址一定都建在旧地址上 然后因为是曼哈顿距离,可以把二维拆成一维来做,以 \(x\) 这维为例,先将其排序 对于 \(i\in[1,m]\) ,拆 \(n+1\) 个点出来 \(S\longrightarrow (i,1)(flow:inf),(i,n+1)\longrightarrow T(flow:inf)\) , \((i,j)\longrightarrow (i,j+1)(flow:cost)\) , \(cost\) 为将第 \(i\) 个地址建在 \(j\) 时,新与旧之间的花费 \((i,k)\longrightarrow (j,k)(flow:a_{i,j}\times (x_{k}-x_{k-1}))(i<j)\) 这样你会发现第 \(i\) 个地址建在 \(b_i\) ,第j个地址建在 \(b_j\) ,那么割掉 \((i,b_i)-(i,b_i+1),(j,b_j)-(j,b_j+1)\) 后,将 \(i,j\) 间 还能 通行的边也得割掉,花费恰好满足题意 来源: https://www.cnblogs.com/Grice/p/12658574.html

XVI Open Cup named after E.V. Pankratiev. GP of Ekaterinburg--I.Iron man

泄露秘密 提交于 2020-04-08 09:08:26
n个服务器,k类任务,每个服务器完成一个任务都有特定的花费$cost_{i,j}$,但是你设置好某台机器去完成某项任务时他只能去完成这类任务,除非你可以花费$C$去更改配置。第$i$天要求去完成$q_{i,j}$个j类任务,问如何让总代价最小 用费用流去优化dp #include <bits/stdc++.h> using namespace std; #define rep(i, j, k) for (int i = int(j); i <= int(k); ++ i) #define dwn(i, j, k) for (int i = int(j); i >= int(k); -- i) typedef long long LL; typedef pair<int, int> P; typedef vector<int> VI; typedef vector<P> VII; const int inf = 1e9; const int N = 50; int cost[20][20], a[110][20], dp[110]; struct Edge { int from, to, cap, flow, cost; }; struct MCMF { int n; vector<Edge> edges; vector<int> g[N]; int inq[N], d[N], p

poj_3281Dining(网络流+拆点)

删除回忆录丶 提交于 2020-04-07 06:27:53
poj_3281Dining(网络流+拆点) 标签: 网络流 题目链接 题意: 一头牛只吃特定的几种食物和特定的几种饮料,John手里每种食物和饮料都只有一个,问最多能够满足几头牛的需求(水和食物都必须和他们的胃口)。 题解: 网络流 建图:从源点向每个食物连一条边,容量为1, 将牛拆成两个点牛,牛',中间连边,容量为1 从食物向牛连边,容量为1 连牛'和饮料,容量为1 连饮料和汇点,容量为1 网络流三种算法的理解和代码实现以及相应的模板 先介绍一个定理: 最大流最小割定理: 割:去掉某几条边使得源点和汇点不再联通,那么这几条边就叫一个割,这几条边的边权和最小的就叫做最小割。 一个图的最大流就是这个图对应的最小割,可以看做是一个沙漏,最大流是要求这个沙漏每个时刻最大的流量,那就相当于是求沙漏最细的地方的流量。而最小割就相当于是用一个刀子将这个沙漏一分为二,然后找横截切面最小的就是这个沙漏最细的地方。 再介绍一些网络流的一些基本性质 流网络G的流(flow)是一个实值函数 f :V ×V → R,且满足下列三个性质 (1) 容量限制:对于∀u,v∈V ,要求 f (u,v) ≤ c(u,v)。 (2) 反对称性:对于∀u,v∈V ,要求 f (u,v) = −f (v,u)。 (3) 流守恒性:对于∀u,v∈V −{s,t},要求∑f (u,v) =0。 f(u,v)即为u到v的流

【网络流24题-18】分配问题 网络流 费用流

无人久伴 提交于 2020-03-30 06:49:40
题目描述   有n件工作要分配给n(n<=100)个人做。第i个人做第 j件工作产生的效益为cij。试设计一个将n件工作分配给n个人做的分配方案,使产生的总效益最大。对于给定的n件工作和 n个人,计算最优分配方案和最差分配方案。 题目大意   见题目描述 A.A 数据范围   见题目描述 A.A 样例输入 5 2 2 2 1 2 2 3 1 2 4 2 0 1 1 1 2 3 4 3 3 3 2 1 2 1 样例输出 5 14 解题思路   S点向人连边,权值为1,费用为0,人向物品连边,权值为1,费用为Cij,物品向T连边,权值为1,费用为0。   最小效益则为最小费用流,最大收益为最大费用流(关于最大费用流的问题,我是将费用取反,最后的答案也取反,当然也可以SPFA求最长路)。 代码 #include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <queue> #define Maxn 23333 #define Maxe 23333 using namespace std; inline int Getint(){int x=0,f=1;char ch=getchar();while('0'

java例程练习(布局管理器[FlowLayout])

血红的双手。 提交于 2020-03-27 04:22:51
//FlowLayout,Panel类的默认布局管理器 import java.awt.*; public class TestLayout { public static void main(String[] args) { Frame f = new Frame("Flow Layout"); Button b1 = new Button("OK"); Button b2 = new Button("Open"); Button b3 = new Button("Close"); f.setLayout(new FlowLayout()); //f.setLayout(new FlowLayout(FlowLayout.LEFT)); //f.setLayout(new FlowLayout(FlowLayout.LEFT,40,50)); f.add(b1); f.add(b2); f.add(b3); f.setSize(100, 100); f.setVisible(true); } } //FlowLayout import java.awt.*; public class TestFlowLayout2 { public static void main(String[] args) { Frame f = new Frame("java Frame");