Haskell 安装 Cairo

news2024/9/22 19:34:49

背景

Haskell 项目需要使用到柱状图,折线图等(demo 代码)

步骤(默认已安装 stack, cabal, ghcup)

nameversion
stack2.11.1
cabal3.8.1.0
ghcup0.1.20.0
  1. 在 package.yaml 中添加所需依赖 Chart 和 Chart-cairo
name:                a
version:             0.1.0.0
github:              "githubuser/a"
license:             BSD-3-Clause
author:              "Author name here"
maintainer:          "example@example.com"
copyright:           "2023 Author name here"

extra-source-files:
- README.md
- CHANGELOG.md

# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description:         Please see the README on GitHub at <https://github.com/githubuser/a#readme>

dependencies:
- base >= 4.7 && < 5

ghc-options:
- -Wall
- -Wcompat
- -Widentities
- -Wincomplete-record-updates
- -Wincomplete-uni-patterns
- -Wmissing-export-lists
- -Wmissing-home-modules
- -Wpartial-fields
- -Wredundant-constraints

library:
  source-dirs: 
  - src
  - app
  dependencies: 
  - bytestring
  - http-conduit
  - sqlite-simple
  - Chart
  - text
  # - Chart-diagrams
  # - diagrams
  # - diagrams-svg
  # - diagrams-lib
  - colour
  - data-default-class
  # common
  - Chart-cairo
  - lens
  - aeson
  - stm
  - split
  - text
  - time
  - binary
  - binary-orphans
  - old-locale
  - directory
  - pretty-simple
  - string-conversions

executables:
  a-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - a
    - sqlite-simple
    - Chart
    - text
    - bytestring
    # - Chart-diagrams
    # - diagrams
    # - diagrams-svg
    # - diagrams-lib
    - colour
    - data-default-class
    # common
    - Chart-cairo
    - lens
    - aeson
    - stm
    - split
    - text
    - time
    - binary
    - binary-orphans
    - old-locale
    - directory
    - pretty-simple
    - string-conversions

tests:
  a-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - a

运行 stack-build,编译失败,大概提示未指定 cairo 版本。

  1. 在 stack.yaml 中添加 chart 版本信息
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
# resolver: lts-21.13
resolver: lts-21.13
  # url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/22.yaml

# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
#   subdirs:
#   - auto-update
#   - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
#   commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []

# Override default flag values for local packages and extra-deps
# flags: {}

# Extra package databases containing global packages
# extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of Stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.11"
#
# Override the architecture used by Stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by Stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
extra-deps:
- Chart-1.9.5
- Chart-cairo-1.9.4.1

flags: {}

extra-package-dbs: []

运行 stack build,报错。

ErrorTrace:

cairo      > configure
cairo      > [1 of 3] Compiling Main             ( C:\Users\df366\AppData\Local\Temp\stack-96faf9bec5d62ffb\cairo-0.13.10.0\Setup.hs, C:\Users\df366\AppData\Local\Temp\stack-96faf9bec5d62ffb\cairo-0.13.10.0\.stack-work\dist\22605e11\setup\Main.o )
cairo      > [2 of 3] Compiling StackSetupShim   ( C:\sr\setup-exe-src\setup-shim-9p6GVs8J.hs, C:\Users\df366\AppData\Local\Temp\stack-96faf9bec5d62ffb\cairo-0.13.10.0\.stack-work\dist\22605e11\setup\StackSetupShim.o )
cairo      > [3 of 3] Linking C:\Users\df366\AppData\Local\Temp\stack-96faf9bec5d62ffb\cairo-0.13.10.0\.stack-work\dist\22605e11\setup\setup.exe
cairo      > Configuring cairo-0.13.10.0...
cairo      > Error: setup.EXE: The pkg-config package 'cairo' version >=1.2.0 is required
cairo      > but it could not be found.
cairo      >
Progress 1/3

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package cairo-0.13.10.0 (scroll up to its section to see the error) using:
       C:\Users\df366\AppData\Local\Temp\stack-96faf9bec5d62ffb\cairo-0.13.10.0\.stack-work\dist\22605e11\setup\setup --verbose=1 --builddir=.stack-work\dist\22605e11 configure --with-ghc=C:\Users\df366\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.7\bin\ghc-9.4.7.exe --with-ghc-pkg=C:\Users\df366\AppData\Local\Programs\stack\x86_64-windows\ghc-9.4.7\bin\ghc-pkg-9.4.7.exe --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\9095fbbf\pkgdb --libdir=C:\sr\snapshots\9095fbbf\lib --bindir=C:\sr\snapshots\9095fbbf\bin --datadir=C:\sr\snapshots\9095fbbf\share --libexecdir=C:\sr\snapshots\9095fbbf\libexec --sysconfdir=C:\sr\snapshots\9095fbbf\etc --docdir=C:\sr\snapshots\9095fbbf\doc\cairo-0.13.10.0 --htmldir=C:\sr\snapshots\9095fbbf\doc\cairo-0.13.10.0 --haddockdir=C:\sr\snapshots\9095fbbf\doc\cairo-0.13.10.0 --dependency=Cabal=Cabal-3.8.1.0 --dependency=array=array-0.5.4.0 --dependency=base=base-4.17.2.0 --dependency=bytestring=bytestring-0.11.5.2 --dependency=gtk2hs-buildtools=gtk2hs-buildtools-0.13.10.0-7OxGn4htize3gcv93EYR9n --dependency=mtl=mtl-2.2.2 --dependency=text=text-2.0.2 --dependency=utf8-string=utf8-string-1.0.2-KqazO8nUWrDMJ2shK7HoQ -fcairo_pdf -fcairo_ps -fcairo_svg --ghc-options -haddock --extra-include-dirs=C:\Users\df366\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\include --extra-lib-dirs=C:\Users\df366\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\lib --extra-lib-dirs=C:\Users\df366\AppData\Local\Programs\stack\x86_64-windows\msys2-20230526\mingw64\bin --exact-configuration --ghc-option=-fhide-source-paths
       Process exited with code: ExitFailure 1

提示 gcc 自带的 pkg-config 没有高于 1.2.0 的 cairo 包

  1. 安装 MSYS2, 并配置 Path, 目的是用到 MSYS2 中的 pkg-config.
    在这里插入图片描述
    安装相关工具
# gcc
pacman -S mingw-w64-ucrt-x86_64-gcc

# gtk
pacman -S mingw-w64-x86_64-gtk4

# 语言开发包
pacman -S mingw-w64-x86_64-toolchain base-devel
  1. 重启 PowerShell 和 VSCode
  2. 在 VSCode 的 PowerShell 中运行
$Env:PATH -split ';'

PS C:\Users\df366\a\a> $Env:PATH -split ';'
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files\dotnet\
C:\Program Files\Docker\Docker\resources\bin
D:\Git\cmd
D:\MSYS2\mingw64\bin
D:\MSYS2\mingw64\lib
D:\MSYS2\mingw64\include
C:\Users\df366\AppData\Roaming\local\bin
C:\Users\df366\AppData\Local\Microsoft\WindowsApps
C:\Users\df366\.dotnet\tools
C:\Program Files\MongoDB\Server\7.0\bin
D:\Microsoft VS Code\bin
C:\ghcup\bin
D:\PyCharm 2023.2.2\bin

注意:这里必须重启 VSCode,否则系统环境中的变量不会更新。

  1. 检查 pkg-config
Get-Command pkg-config

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     pkg-config.exe                                     0.0.0.0    D:\MSYS2\mingw64\bin\pkg-config.exe

发现 pkg-config 已经变成 MSYS2 下的了

  1. 重新执行 stack build,运行成功
PS C:\Users\df366\a\a> stack build
a-0.1.0.0: unregistering (local file changes: app\Main.hs)
a> build (lib + exe)
Preprocessing library for a-0.1.0.0..
Building library for a-0.1.0.0..
[6 of 7] Compiling Main [Source file changed]

app\Main.hs:3:1: warning: [-Wunused-imports]
    The import of 鈥楩etch鈥?is redundant

      except perhaps to import instances from 鈥楩etch鈥?[0m

    To import instances alone, use: import Fetch()
  |
3 | import Fetch
  | ^^^^^^^^^^^^

app\Main.hs:4:1: warning: [-Wunused-imports]
    The import of 鈥楧ata.Text鈥?is redundant

      except perhaps to import instances from 鈥楧ata.Text鈥?[0m

    To import instances alone, use: import Data.Text()
  |
4 | import Data.Text (Text, splitOn)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app\Main.hs:5:1: warning: [-Wunused-imports]
    The qualified import of 鈥楧ata.Text鈥?is redundant

      except perhaps to import instances from 鈥楧ata.Text鈥?[0m

    To import instances alone, use: import Data.Text()
  |
5 | import qualified Data.Text as T
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app\Main.hs:6:1: warning: [-Wunused-imports]
    The import of 鈥楧atabase鈥?is redundant

      except perhaps to import instances from 鈥楧atabase鈥?[0m

    To import instances alone, use: import Database()
  |
6 | import Database
  | ^^^^^^^^^^^^^^^
[7 of 7] Linking app\Main.exe [Objects changed]
Preprocessing executable 'a-exe' for a-0.1.0.0..
Building executable 'a-exe' for a-0.1.0.0..
[1 of 2] Compiling Main [Source file changed]

app\Main.hs:3:1: warning: [-Wunused-imports]
    The import of 鈥楩etch鈥?is redundant

      except perhaps to import instances from 鈥楩etch鈥?[0m

    To import instances alone, use: import Fetch()
  |
3 | import Fetch
  | ^^^^^^^^^^^^

app\Main.hs:4:1: warning: [-Wunused-imports]
    The import of 鈥楧ata.Text鈥?is redundant

      except perhaps to import instances from 鈥楧ata.Text鈥?[0m

    To import instances alone, use: import Data.Text()
  |
4 | import Data.Text (Text, splitOn)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app\Main.hs:5:1: warning: [-Wunused-imports]
    The qualified import of 鈥楧ata.Text鈥?is redundant

      except perhaps to import instances from 鈥楧ata.Text鈥?[0m

    To import instances alone, use: import Data.Text()
  |
5 | import qualified Data.Text as T
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

app\Main.hs:6:1: warning: [-Wunused-imports]
    The import of 鈥楧atabase鈥?is redundant

      except perhaps to import instances from 鈥楧atabase鈥?[0m

    To import instances alone, use: import Database()
  |
6 | import Database
  | ^^^^^^^^^^^^^^^
[3 of 3] Linking .stack-work\dist\22605e11\build\a-exe\a-exe.exe [Objects changed]
a> copy/register
Installing library in C:\Users\df366\a\a\.stack-work\install\1b692ffa\lib\x86_64-windows-ghc-9.4.7\a-0.1.0.0-5LEhwaAmmakDiuPZZmv67T
Installing executable a-exe in C:\Users\df366\a\a\.stack-work\install\1b692ffa\bin
Registering library for a-0.1.0.0..
  1. Main 代码
module Main (main) where

import Fetch
import Data.Text (Text, splitOn)
import qualified Data.Text as T
import Database
-- import Diagrams.Prelude
-- import Diagrams.Backend.SVG
-- import Diagrams.Attributes
-- import Diagrams.Backend.SVG.CmdLine

import Graphics.Rendering.Chart
import Graphics.Rendering.Chart.Backend.Cairo
import Data.Colour
import Control.Lens
import Data.Default.Class

chart :: Bool -> Renderable ()
chart borders = toRenderable layout
 where
  layout =
        layout_title .~ "Sample Bars" ++ btitle
      $ layout_title_style . font_size .~ 10
      $ layout_x_axis . laxis_generate .~ autoIndexAxis alabels
      $ layout_y_axis . laxis_override .~ axisGridHide
      $ layout_left_axis_visibility . axis_show_ticks .~ False
      $ layout_plots .~ [ plotBars bars2 ]
      $ def :: Layout PlotIndex Double

  bars2 = plot_bars_titles .~ ["Cash","Equity"]
      $ plot_bars_values .~ addIndexes [[20,45],[45,30],[30,20],[70,25]]
      $ plot_bars_style .~ BarsClustered
      $ plot_bars_spacing .~ BarsFixGap 30 5
      $ plot_bars_item_styles .~ map mkstyle (cycle defaultColorSeq)
      $ def

  alabels = [ "Jun", "Jul", "Aug", "Sep", "Oct" ]

  btitle = if borders then "" else " (no borders)"
  bstyle = if borders then Just (solidLine 1.0 $ opaque black) else Nothing
  mkstyle c = (solidFillStyle c, bstyle)

main :: IO ()
main = do
  _ <- renderableToFile def "example11_big.png" (chart True)
  return ()

-- spilitByLine :: String -> [String]
-- spilitByLine s = map T.unpack $ splitOn (T.pack "\n") (T.pack s)

-- main :: IO ()
-- main = do
--     a <- downloadURL "http://prod.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-2022.csv"

--     let items = spilitByLine a
--     print $ length items
--     print $ head items
--     print $ items !! 1
--     print 33
--     print "3.6.2.0"
    
  1. 输出图
    在这里插入图片描述

  2. cabal 文件(无需修改,在 package.yaml 添加依赖后,运行 stack update 会同步更新)

cabal-version: 2.2

-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack

name:           a
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/githubuser/a#readme>
homepage:       https://github.com/githubuser/a#readme
bug-reports:    https://github.com/githubuser/a/issues
author:         Author name here
maintainer:     example@example.com
copyright:      2023 Author name here
license:        BSD-3-Clause
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    README.md
    CHANGELOG.md

source-repository head
  type: git
  location: https://github.com/githubuser/a

library
  exposed-modules:
      Database
      Fetch
      Lib
      Types
      Main
  other-modules:
      Paths_a
  autogen-modules:
      Paths_a
  hs-source-dirs:
      src
      app
  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
  build-depends:
      Chart
    , Chart-cairo
    , aeson
    , base >=4.7 && <5
    , binary
    , binary-orphans
    , bytestring
    , colour
    , data-default-class
    , directory
    , http-conduit
    , lens
    , old-locale
    , pretty-simple
    , split
    , sqlite-simple
    , stm
    , string-conversions
    , text
    , time
  default-language: Haskell2010

executable a-exe
  main-is: Main.hs
  other-modules:
      Paths_a
  autogen-modules:
      Paths_a
  hs-source-dirs:
      app
  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      Chart
    , Chart-cairo
    , a
    , aeson
    , base >=4.7 && <5
    , binary
    , binary-orphans
    , bytestring
    , colour
    , data-default-class
    , directory
    , lens
    , old-locale
    , pretty-simple
    , split
    , sqlite-simple
    , stm
    , string-conversions
    , text
    , time
  default-language: Haskell2010

test-suite a-test
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_a
  autogen-modules:
      Paths_a
  hs-source-dirs:
      test
  ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      a
    , base >=4.7 && <5
  default-language: Haskell2010

参考博客:
https://stackoverflow.com/questions/57940965/pkg-config-installed-but-not-found
https://stackoverflow.com/questions/44314060/haskell-stack-nix-build-fails-requiring-pkg-config-0-9-0-and-cairo-1
https://stackoverflow.com/questions/5336865/cant-install-cairo-with-cabal-on-windows-how-to-get-pkg-config-on-win
https://stackoverflow.com/questions/63396432/having-dependency-issues-while-trying-to-install-threadscope-with-stack-the-iss
https://github.com/commercialhaskell/stack/issues/377
https://stackoverflow.com/questions/77441659/haskell-after-install-the-conduit-package
https://zhuanlan.zhihu.com/p/623146940

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1264310.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Ruoyi-cloud / 若依 SpringCloud服务器部署

1、redis 环境 服务器安装redis &#xff0c;注意 密码 端口 2、mysql 环境 服务器安装 mysql 5.7 以上的版本 代码中的sql 文件夹中有 sql 文件 创建数据库ry-cloud并导入数据脚本ry_2021xxxx.sql&#xff08;必须&#xff09;&#xff0c;quartz.sql&#xff08;可选&…

更快更稳的剃须伙伴,DOCO黑刃电动剃须刀体验

现在的电动剃须刀选择很多&#xff0c;我觉得三刀头的旋转式剃须刀很好用&#xff0c;比如我目前用的这款DOCO黑刃剃须刀&#xff0c;在剃须效率、舒适度和易用性等方面都表现不错&#xff0c;很适合日常使用。 这款剃须刀采用磁吸式刀头&#xff0c;这一设计非常方便清洁与更换…

docker容器入门

docker容器入门 1.1 容器介绍 容器技术是一种操作系统级的虚拟化技术&#xff0c;它允许在一个物理或虚拟机上运行多个隔离的应用程序实例&#xff0c;每个实例都被封装在一个独立的容器中。每个容器都包含应用程序及其依赖的运行时环境&#xff0c;如操作系统、库文件和配置…

【代码随想录】算法训练计划35

贪心 1、860. 柠檬水找零 题目&#xff1a; 输入&#xff1a;bills [5,5,5,10,20] 输出&#xff1a;true 思路&#xff1a; 模拟大法 func lemonadeChange(bills []int) bool {//贪心&#xff0c;代码一刷&#xff0c; 感觉要用到hashmap&#xff0c;也不用five, ten : 0…

文件操作在 Python 中的基本用法

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 文件操作是任何编程语言中都至关重要的一部分&#xff0c;Python 提供了简单而强大的文件操作功能&#xff0c;使得读取、写入和处理文件变得非常便捷。本文将详细介绍 Python 中文件操作的基本用法&#xff0c;…

SpringBoot使用动态Banner

SpringBoot使用动态Banner Spring Boot 2.0 提供了很多新特性&#xff0c;其中就有动态 Banner。 1、pom依赖 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://w…

sizeof 和 strlen的对比及笔试题目

目录 题目1&#xff1a; 题目2&#xff1a; 题目3&#xff1a; 题目4&#xff1a; 题目5&#xff1a; 题目6&#xff1a; 二维数组题&#xff08;重点&#xff09;&#xff1a; 上述题目总结&#xff1a; 若想了解其他的字符函数和字符串函数请移步&#xff1a;深入理解…

Gin投票系统(2)

投票系统 数据库的建立 先分析需求&#xff0c;在sql中建立数据库&#xff0c;关于项目数据库如何建立可以在“goweb项目创建流程分析中看如何去建表” 成功后目前有四个表&#xff1a; vote&#xff0c;user&#xff0c;vote_opt,vote_opt_user 建立数据库&#xff0c;可以…

万字解析设计模式之迭代器模式、备忘录模式

一、迭代器模式 1.1概述 迭代器模式是一种行为型设计模式&#xff0c;它允许在没有暴露其底层表现形式的情况下遍历集合对象。迭代器模式提供一种通用的遍历机制&#xff0c;可以遍历任何类型的集合&#xff0c;包括数组、列表、树等。通过这种模式&#xff0c;可以实现一种通…

微信小程序 老年人心血管健康知识科普系统

本系统的功能有管理员&#xff1a;个人中心&#xff0c;用户管理&#xff0c;热点信息管理&#xff0c;疾病管理&#xff0c;疾病类型管理&#xff0c;治疗管理&#xff0c;治疗类型管理&#xff0c;护理管理&#xff0c;护理类型管理&#xff0c;科普管理&#xff0c;科普类型…

Microsoft Office Exce-筛选后的公式批量复制粘贴为值 并且不乱数据

Microsoft Office Exce-利用选择性粘贴将筛选后的公式结果批量转换为值 1、写好【客单价】公式&#xff0c;并下拉填充 &#xff08;【SKU】、【销售额】、【销售量】这三列都是常量&#xff0c;非公式&#xff09; 2、复制客单价公式到E列 3、筛选数据&#xff0c; 按 Delet…

成员内部类(内部类) - Java

成员内部类 说明&#xff1a;成员内部类是定义在外部类的成员位置&#xff0c;并且没有static修饰。 可以直接访问外部类的所有成员&#xff0c;包含私有的。【案例a】可以添加任意访问修饰符&#xff08;public、protected、默认、private&#xff09;&#xff0c;因为它的地…

数组中的第 K 个最大元素(C++实现)

数组中的第 K 个最大元素 题目思路代码 题目 数组中的第 K 个最大元素 思路 通过使用优先队列&#xff08;最大堆&#xff09;来找到数组中第k大的元素。通过弹出最大堆中的前k-1个元素&#xff0c;留下堆中的顶部元素作为结果返回。 代码 class Solution { public:int find…

某东大厂面试js手写题【手写代码附带注释,放心食用,博主亲测】

文章目录 前言js实现push方法js实现订阅发布手写防抖节流手写reduce方法深拷贝es5去重数组多维数组去重排序简单递归实现树形结构输出遍历后言 前言 hello world欢迎来到前端的新世界 &#x1f61c;当前文章系列专栏&#xff1a;前端面试 &#x1f431;‍&#x1f453;博主在前…

摄影网站的技术 SEO:提示和最佳实践

摄影就是要给人留下良好的第一印象。如果你想在竞争中领先&#xff0c;摄影师的SEO是您可以采用的最佳营销方法之一。 我们都曾有过这样的经历&#xff1a;你建立了一个漂亮的作品集网站来吸引更多的业务。网站上线并在社交媒体上推广后&#xff0c;您就可以坐等了。网站访问量…

线程池在Java中的应用实践

摘要&#xff1a;在实际业务场景中&#xff0c;线程池发挥着重要作用。本文将详细解答在高并发、任务执行时间短、并发不高、任务执行时间长以及并发高、业务执行时间长的业务场景下&#xff0c;如何使用线程池进行优化。 一、高并发、任务执行时间短的业务场景 在高并发、任务…

python服装电商系统vue购物商城django-pycharm毕业设计项目推荐

系统面向的使用群体为商家和消费者&#xff0c;商家和消费者所承担的功能各不相同&#xff0c;所对象的权限也各不相同。对于消费者和商家设计的功能如下&#xff1a; 对于消费者设计了五大功能模块&#xff1a; &#xff08;1&#xff09; 商品信息&#xff1a;用户可在商品…

【黑马甄选离线数仓day06_核销主题域开发】

1. 核销主题_DWD和DWM层 1.0 ODS层 操作数据存储层: Operate Data Store 核心理念: 几乎和源数据保持一致,粒度相同 注意事项: 同步方式(全量同步,全量覆盖,增量仅新增,增量新增和更新) 内部表 分区表(部分) 指定字符分隔符 orc zlib 第二天的时候已经完成了从mysql以及sq…

蓝蜂虚拟网络工具配置说明

虚拟网络工具配置说明 注意&#xff1a; 1、在使用虚拟网络工具前&#xff0c;需保证EG20网关可以连接到EMCP云平台&#xff0c;并且设备已经绑定在对应的账号下&#xff0c;同时固件版本为v1.6.6以上。如果不是&#xff0c;点击固件版本处的更新&#xff0c;如下图所示。 2…

GitHub----使用记录

一、上传文件到仓库 1、首先新建一个github仓库 然后先记住这一句指令 2、下载git工具 https://git-scm.com/downloads 下载工具安装不用运行 3、使用git工具上传文件并推送 找到你想上传的文件的位置&#xff0c;右击git Bush here git init &#xff1a;初始化这个仓…